- this.authService.login(username, password).subscribe(
- () => this.router.navigate(['/videos/list']),
+ this.authService.login(username, password)
+ .subscribe(
+ () => this.redirectService.redirectToHomepage(),
+
+ err => {
+ if (err.message.indexOf('credentials are invalid') !== -1) this.error = this.i18n('Incorrect username or password.')
+ else if (err.message.indexOf('blocked') !== -1) this.error = this.i18n('You account is blocked.')
+ else this.error = err.message
+ }
+ )
+ }
+
+ askResetPassword () {
+ this.userService.askResetPassword(this.forgotPasswordEmail)
+ .subscribe(
+ res => {
+ const message = this.i18n(
+ 'An email with the reset password instructions will be sent to {{email}}.',
+ { email: this.forgotPasswordEmail }
+ )
+ this.notificationsService.success(this.i18n('Success'), message)
+ this.hideForgotPasswordModal()
+ },
+
+ err => this.notificationsService.error(this.i18n('Error'), err.message)
+ )
+ }
+
+ onForgotPasswordModalShown () {
+ this.forgotPasswordEmailInput.nativeElement.focus()
+ }
+
+ openForgotPasswordModal () {
+ this.forgotPasswordModal.show()
+ }