Finished implementing user settings -> security
This commit is contained in:
@@ -2,6 +2,7 @@ import {Component, inject, signal} from '@angular/core';
|
||||
import {TranslatePipe} from '@ngx-translate/core';
|
||||
import {TuiBadge, TuiButtonLoading, TuiInputNumber} from '@taiga-ui/kit';
|
||||
import {
|
||||
TUI_BREAKPOINT,
|
||||
TuiButton,
|
||||
TuiDialog,
|
||||
TuiErrorComponent,
|
||||
@@ -41,6 +42,7 @@ import {
|
||||
})
|
||||
export class Email {
|
||||
serviceManager = inject(ServiceManager)
|
||||
breakpoint = inject(TUI_BREAKPOINT)
|
||||
|
||||
step = signal(0)
|
||||
changeEmailDialogOpen = signal(false)
|
||||
@@ -74,18 +76,22 @@ export class Email {
|
||||
}
|
||||
|
||||
async changeEmail(currentPassword: string | null, newMail: string | null) {
|
||||
if (this.changeEmailRemoveMode()) {
|
||||
newMail = "remove"
|
||||
}
|
||||
this.changeEmailPending.set(true)
|
||||
const service = this.serviceManager.currentSessionHandler
|
||||
if (service) {
|
||||
try {
|
||||
await service.changeEmail(newMail ?? "", currentPassword ?? "")
|
||||
this.step.set(1)
|
||||
this.newAddress = newMail ?? ""
|
||||
if (!this.changeEmailRemoveMode()) {
|
||||
this.newAddress = newMail ?? ""
|
||||
this.verifyEmailForm.controls["oldCode"].setValidators([Validators.required])
|
||||
this.step.set(1)
|
||||
}
|
||||
} catch (e) {
|
||||
this.changeEmailForm.controls["currentPassword"].setErrors({incorrect: true})
|
||||
this.changeEmailPending.set(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -99,6 +105,7 @@ export class Email {
|
||||
this.changeEmailDialogOpen.set(false)
|
||||
} catch (e) {
|
||||
this.verifyEmailForm.controls["newCode"].setErrors({incorrect: true})
|
||||
this.verifyEmailPending.set(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user