Skip to content

Commit

Permalink
Display password change errors (#3056)
Browse files Browse the repository at this point in the history
  • Loading branch information
bastianjoel authored Dec 1, 2023
1 parent 9f8522c commit acb7614
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
7 changes: 5 additions & 2 deletions client/src/app/gateways/error-mapping/error-map-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { marker as _ } from '@colsen1991/ngx-translate-extract-marker';

import { MeetingAction } from '../repositories/meetings';
import { MotionAction } from '../repositories/motions';
import { UserAction } from '../repositories/users/user-action';

export class MapError {
public constructor(private message: string) {}
Expand Down Expand Up @@ -39,7 +40,7 @@ const VoteServiceErrorMap: ErrorMap = new ErrorMap([
[/is not allowed to vote/, _(`You do not have the permission to vote.`)]
]);

const MotionCreateForwardErrorMap: ErrorMap = new ErrorMap([[/(.*)/, input => new MapError(input)]]);
const MatchAllErrorMap: ErrorMap = new ErrorMap([[/(.*)/, input => new MapError(input)]]);
const MeetingCreateErrorMap: ErrorMap = new ErrorMap([
[
/Only one of start_time and end_time is not allowed./,
Expand All @@ -57,7 +58,9 @@ const getActionErrorMap: (data: any) => ErrorMap | null = data => {
case MeetingAction.CREATE:
return MeetingCreateErrorMap;
case MotionAction.CREATE_FORWARDED:
return MotionCreateForwardErrorMap;
case UserAction.FORGET_PASSWORD_CONFIRM:
case UserAction.SET_PASSWORD_SELF:
return MatchAllErrorMap;
default:
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,22 @@ export class AccountDialogComponent extends BaseUiComponent implements OnInit {

public async changePassword(): Promise<void> {
const { oldPassword, newPassword }: PasswordForm = this.userPasswordForm;
this.repo.setPasswordSelf(this.self!, oldPassword, newPassword).then(() => {
this.snackbar.open(this.translate.instant(`Password changed successfully!`), `Ok`);
this.changePasswordComponent.reset();
});

this.repo
.setPasswordSelf(this.self!, oldPassword, newPassword)
.then(() => {
this.snackbar.open(this.translate.instant(`Password changed successfully!`), `Ok`);
this.changePasswordComponent.reset();
})
.catch(e => {
if (e?.message) {
this.snackbar.open(this.translate.instant(e.message), this.translate.instant(`OK`), {
duration: 0
});
}

console.log(e);
});
}

public async saveUserChanges(): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class ResetPasswordConfirmComponent extends BaseComponent implements OnIn
authorization_token: this.token,
new_password: this.newPasswordForm.get(`password`)!.value
});
// TODO: Does we get a response for displaying?

this.matSnackBar.open(
this.translate.instant(`Your password has been reset successfully!`),
this.translate.instant(`OK`),
Expand All @@ -95,6 +95,12 @@ export class ResetPasswordConfirmComponent extends BaseComponent implements OnIn
);
this.router.navigate([`/login`]);
} catch (e) {
if (e?.message) {
this.matSnackBar.open(this.translate.instant(e.message), this.translate.instant(`OK`), {
duration: 0
});
}

console.log(`error`, e);
}
}
Expand Down

0 comments on commit acb7614

Please sign in to comment.