From a60719bcc4721ba5d6cda669ce354664352797ad Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Tue, 23 Jul 2019 12:03:54 +0200 Subject: [PATCH] Added error message for connection refused errors sending emails --- client/src/app/site/base/base-view.ts | 2 +- .../reset-password/reset-password.component.ts | 15 +++++++-------- openslides/users/views.py | 6 ++++++ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/client/src/app/site/base/base-view.ts b/client/src/app/site/base/base-view.ts index 97fa404f9..5a0b35213 100644 --- a/client/src/app/site/base/base-view.ts +++ b/client/src/app/site/base/base-view.ts @@ -29,7 +29,7 @@ export abstract class BaseViewComponent extends BaseComponent implements OnDestr * @param translate the translate service, passed to the base component * @param matSnackBar the snack bar service. Needed for showing errors. */ - public constructor(titleService: Title, translate: TranslateService, private matSnackBar: MatSnackBar) { + public constructor(titleService: Title, translate: TranslateService, protected matSnackBar: MatSnackBar) { super(titleService, translate); this.subscriptions = []; } diff --git a/client/src/app/site/login/components/reset-password/reset-password.component.ts b/client/src/app/site/login/components/reset-password/reset-password.component.ts index b19a8200b..8d1e7122a 100644 --- a/client/src/app/site/login/components/reset-password/reset-password.component.ts +++ b/client/src/app/site/login/components/reset-password/reset-password.component.ts @@ -7,9 +7,9 @@ import { Router } from '@angular/router'; import { TranslateService } from '@ngx-translate/core'; import { environment } from 'environments/environment'; -import { BaseComponent } from '../../../../base.component'; import { HttpService } from 'app/core/core-services/http.service'; import { ThemeService } from 'app/core/ui-services/theme.service'; +import { BaseViewComponent } from 'app/site/base/base-view'; /** * Reset password component. @@ -20,7 +20,7 @@ import { ThemeService } from 'app/core/ui-services/theme.service'; templateUrl: './reset-password.component.html', styleUrls: ['../../assets/reset-password-pages.scss'] }) -export class ResetPasswordComponent extends BaseComponent implements OnInit { +export class ResetPasswordComponent extends BaseViewComponent implements OnInit { /** * THis form holds one control for the email. */ @@ -30,15 +30,15 @@ export class ResetPasswordComponent extends BaseComponent implements OnInit { * Constructur for the reset password view. Initializes the form for the email. */ public constructor( - protected titleService: Title, - protected translate: TranslateService, + titleService: Title, + translate: TranslateService, + matSnackBar: MatSnackBar, private http: HttpService, formBuilder: FormBuilder, - private matSnackBar: MatSnackBar, private router: Router, private themeService: ThemeService ) { - super(titleService, translate); + super(titleService, translate, matSnackBar); this.resetPasswordForm = formBuilder.group({ email: ['', [Validators.required, Validators.email]] }); @@ -64,7 +64,6 @@ export class ResetPasswordComponent extends BaseComponent implements OnInit { await this.http.post(environment.urlPrefix + '/users/reset-password/', { email: this.resetPasswordForm.get('email').value }); - // TODO: Does we get a response for displaying? this.matSnackBar.open( this.translate.instant('An email with a password reset link was send!'), this.translate.instant('OK'), @@ -74,7 +73,7 @@ export class ResetPasswordComponent extends BaseComponent implements OnInit { ); this.router.navigate(['/login']); } catch (e) { - console.log('error', e); + this.raiseError(e); } } } diff --git a/openslides/users/views.py b/openslides/users/views.py index 3f8caf3cc..03aeeff8c 100644 --- a/openslides/users/views.py +++ b/openslides/users/views.py @@ -838,6 +838,12 @@ class PasswordResetView(APIView): "detail": f"Error {e.smtp_code}: Authentication failure. Please contact your administrator." } ) + except ConnectionRefusedError: + raise ValidationError( + { + "detail": "Connection refused error. Please contact your administrator." + } + ) return super().post(request, *args, **kwargs) def get_users(self, email):