Skip to content

Commit

Permalink
Merge pull request #50 from Donnerstagnacht/read-me
Browse files Browse the repository at this point in the history
Implement password reset functionality
  • Loading branch information
Donnerstagnacht authored Jan 3, 2024
2 parents ad26f84 + a319167 commit e165c6b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,14 @@
├── cypress: End-2-End tests organized by features
│ ├── e2e: End to end tests ordered by execution
│ │ └── Feature: according to front end
│ ├── fixtures: static test files and test data objects
│ ├── fixtures: specific test variables
│ └── support
│ ├── commands: Definition of cypress commonands
│ └── index.d.ts: Signature and types of cypress commands
├── seed_and_test_data
│ └── Data used to seed database and set test states
├── src
│ ├── app: Frontend
│ │ ├── auth: Authentication functionality
Expand Down
22 changes: 19 additions & 3 deletions src/app/auth/services/authentication.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,19 @@ export class AuthenticationService {
}
}

/**
* Updates the email of the user.
*
* @param {string} newEmail - The new email address to update.
* @return {Promise<{ user: User } | unknown>} - A promise that resolves to an an object containing the updated user data or an unknown error.
*/
public async updateEmail(newEmail: string): Promise<{ user: User } | unknown> {
try {
this.sessionStoreService.loading.startLoading()
const userResponse: UserResponse = await this.supabaseClient.auth.updateUser({email: newEmail})
if (userResponse.error) {
throw userResponse.error;
}
console.log(userResponse.data)
this.tuiAlertService.open(
'Email erfolgreich geändert. Die Änderung muss in der Alten und Neuen Email-Adresse bestätigt werden' +
' und wird dann beim nächsten Login benötigt.',
Expand All @@ -149,14 +154,20 @@ export class AuthenticationService {
}
}

/**
* Updates the password of the current user.
*
* @param {string} newPassword - The new password to be set.
* @returns {Promise<{ user: User } | unknown>} A Promise that resolves to either an object containing the
* updated user data or an unknown error.
*/
public async updatePassword(newPassword: string): Promise<{ user: User } | unknown> {
try {
this.sessionStoreService.loading.startLoading()
const userResponse: UserResponse = await this.supabaseClient.auth.updateUser({password: newPassword})
if (userResponse.error) {
throw userResponse.error;
}
console.log(userResponse.data)
this.tuiAlertService.open(
'Passwort erfolgreich geändert und beim nächsten Login benötigt.',
{
Expand All @@ -173,6 +184,12 @@ export class AuthenticationService {
}
}

/**
* Requests a password reset for the given email address.
*
* @param {string} emailResetShouldBeSend - The email address to send the password reset to.
* @returns {Promise<any>} - A Promise that resolves to the response data, or rejects with an error.
*/
public async requestPasswordReset(emailResetShouldBeSend: string): Promise<any> {
try {
this.sessionStoreService.loading.startLoading()
Expand All @@ -186,7 +203,6 @@ export class AuthenticationService {
if (userResponse.error) {
throw userResponse.error;
}
console.log(userResponse.data)
this.tuiAlertService.open(
'Email erfolgreich versendet. Öffne deinen Email Account.',
{
Expand Down

0 comments on commit e165c6b

Please sign in to comment.