Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable reset password for signed in users #2308

Merged
merged 2 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</div>

<div class="form-group">
<button type="submit" id="signup" class="button button-primary">
<button type="submit" id="signup" class="button button-primary" data-bind="attr: { disabled: isResetPasswordDisabled() }">
Reset
</button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ export class ConfirmPassword {
public readonly password: ko.Observable<string>;
public readonly passwordConfirmation: ko.Observable<string>;
public readonly isResetConfirmed: ko.Observable<boolean>;
public readonly working: ko.Observable<boolean>;
public readonly isResetPasswordDisabled: ko.Observable<boolean>;

constructor(
private readonly usersService: UsersService,
private readonly eventManager: EventManager) {
this.password = ko.observable();
this.passwordConfirmation = ko.observable();
this.isResetConfirmed = ko.observable(false);
this.working = ko.observable(false);
this.isResetPasswordDisabled = ko.observable(true);

validation.init({
insertMessages: false,
Expand All @@ -49,6 +49,7 @@ export class ConfirmPassword {
this.userId = await this.usersService.getCurrentUserId();

if (this.userId) {
dispatchErrors(this.eventManager, ErrorSources.confirmpassword, ["Cannot reset password for a signed in user."]);
return;
}

Expand All @@ -69,12 +70,19 @@ export class ConfirmPassword {
} catch (error) {
dispatchErrors(this.eventManager, ErrorSources.confirmpassword, ["Activate user error: " + error.message]);
}

this.isResetPasswordDisabled(false);
}

/**
* Sends user resetPswd request to Management API.
*/
public async resetPswd(): Promise<void> {
if (this.token == undefined || this.userId == undefined) {
dispatchErrors(this.eventManager, ErrorSources.confirmpassword, ["Required params not found"]);
return;
}

const result = validation.group({
password: this.password,
passwordConfirmation: this.passwordConfirmation
Expand Down
Loading