From 06928fe245042e7d16943482ae3c2e745493c0cd Mon Sep 17 00:00:00 2001 From: Chneemann Date: Fri, 30 Aug 2024 10:59:39 +0200 Subject: [PATCH] buttons cannot be clicked multiple times --- frontend/src/app/components/auth/auth.component.html | 5 ++++- frontend/src/app/components/auth/auth.component.ts | 3 +++ .../auth/forgot-password/forgot-password.component.html | 5 +++-- .../auth/forgot-password/forgot-password.component.ts | 7 +++++-- .../src/app/components/auth/login/login.component.html | 7 +++++-- frontend/src/app/components/auth/login/login.component.ts | 4 ++++ .../app/components/auth/register/register.component.html | 3 ++- .../src/app/components/auth/register/register.component.ts | 3 +++ .../components/auth/verify-email/verify-email.component.ts | 3 +++ 9 files changed, 32 insertions(+), 8 deletions(-) diff --git a/frontend/src/app/components/auth/auth.component.html b/frontend/src/app/components/auth/auth.component.html index 82c7710..218fc95 100644 --- a/frontend/src/app/components/auth/auth.component.html +++ b/frontend/src/app/components/auth/auth.component.html @@ -39,7 +39,10 @@ [imgPath]="'play'" [imgPath]="'arrow_right'" [imgReverse]="true" - [disabled]="!isUserEmailValid(authData.mail) && authData.mail.length > 0" + [disabled]=" + (!isUserEmailValid(authData.mail) && authData.mail.length > 0) || + authData.send + " > diff --git a/frontend/src/app/components/auth/auth.component.ts b/frontend/src/app/components/auth/auth.component.ts index 2902814..34ad1ce 100644 --- a/frontend/src/app/components/auth/auth.component.ts +++ b/frontend/src/app/components/auth/auth.component.ts @@ -16,6 +16,7 @@ import { AuthService } from '../../services/auth.service'; export class AuthComponent { authData = { mail: '', + send: false, }; constructor( @@ -42,11 +43,13 @@ export class AuthComponent { email: this.authData.mail, }; try { + this.authData.send = true; await this.authService.checkAuthUserMail(body); const queryParams = { mail: this.authData.mail }; this.router.navigate(['/register'], { queryParams }); this.errorService.clearError(); } catch (error) { + this.authData.send = false; this.errorService.handleError(error); } } diff --git a/frontend/src/app/components/auth/forgot-password/forgot-password.component.html b/frontend/src/app/components/auth/forgot-password/forgot-password.component.html index fc68bc3..f9bf168 100644 --- a/frontend/src/app/components/auth/forgot-password/forgot-password.component.html +++ b/frontend/src/app/components/auth/forgot-password/forgot-password.component.html @@ -38,7 +38,7 @@ } @else { @if (sendMailSuccess) { @@ -132,7 +132,8 @@ !isUserEmailValid(authData.mail) || authData.password !== authData.passwordConfirm || !authData.password || - !authData.passwordConfirm + !authData.passwordConfirm || + authData.send " > diff --git a/frontend/src/app/components/auth/forgot-password/forgot-password.component.ts b/frontend/src/app/components/auth/forgot-password/forgot-password.component.ts index 9cd4c1b..409f54c 100644 --- a/frontend/src/app/components/auth/forgot-password/forgot-password.component.ts +++ b/frontend/src/app/components/auth/forgot-password/forgot-password.component.ts @@ -19,6 +19,7 @@ export class ForgotPasswordComponent implements OnInit { token: '', password: '', passwordConfirm: '', + send: false, }; sendMailSuccess: boolean = false; @@ -70,10 +71,12 @@ export class ForgotPasswordComponent implements OnInit { email: this.authData.mail, }; try { + this.authData.send = true; await this.authService.forgotPassword(body); this.sendMailSuccess = true; this.errorService.clearError(); } catch (error) { + this.authData.send = false; this.sendMailSuccess = false; this.errorService.handleError(error); } @@ -85,14 +88,14 @@ export class ForgotPasswordComponent implements OnInit { token: this.authData.token, new_password: this.authData.password, }; - console.log(body); - try { + this.authData.send = true; await this.authService.changePassword(body); this.queryEmail = false; this.queryEmailSuccess = true; this.errorService.clearError(); } catch (error) { + this.authData.send = false; this.errorService.handleError(error); } } diff --git a/frontend/src/app/components/auth/login/login.component.html b/frontend/src/app/components/auth/login/login.component.html index a7c82f5..f8d20d3 100644 --- a/frontend/src/app/components/auth/login/login.component.html +++ b/frontend/src/app/components/auth/login/login.component.html @@ -83,13 +83,16 @@ !authData.mail || (!isUserEmailValid(authData.mail) && authData.mail.length > 0) || !password.valid || - authData.guestLogin + authData.guestLogin || + authData.send " > diff --git a/frontend/src/app/components/auth/login/login.component.ts b/frontend/src/app/components/auth/login/login.component.ts index 9cb48f9..e02afa9 100644 --- a/frontend/src/app/components/auth/login/login.component.ts +++ b/frontend/src/app/components/auth/login/login.component.ts @@ -45,6 +45,7 @@ export class LoginComponent { password: environment.guestPassword, }; try { + this.authData.send = true; await this.authService.login(body, this.authData.checkbox); this.authData.mail = ''; this.authData.password = ''; @@ -52,6 +53,7 @@ export class LoginComponent { this.router.navigate(['/browse/']); this.errorService.clearError(); } catch (error) { + this.authData.send = false; this.errorService.handleError(error); } } @@ -63,11 +65,13 @@ export class LoginComponent { password: this.authData.password, }; try { + this.authData.send = true; await this.authService.login(body, this.authData.checkbox); ngForm.resetForm(); this.router.navigate(['/browse/']); this.errorService.clearError(); } catch (error) { + this.authData.send = false; this.errorService.handleError(error); } } diff --git a/frontend/src/app/components/auth/register/register.component.html b/frontend/src/app/components/auth/register/register.component.html index e702618..6da5173 100644 --- a/frontend/src/app/components/auth/register/register.component.html +++ b/frontend/src/app/components/auth/register/register.component.html @@ -123,7 +123,8 @@ authData.password !== authData.passwordConfirm || !authData.password || !authData.passwordConfirm || - !authData.privacyPolicy + !authData.privacyPolicy || + authData.send " > diff --git a/frontend/src/app/components/auth/register/register.component.ts b/frontend/src/app/components/auth/register/register.component.ts index 52e4ad9..bcdc327 100644 --- a/frontend/src/app/components/auth/register/register.component.ts +++ b/frontend/src/app/components/auth/register/register.component.ts @@ -19,6 +19,7 @@ export class RegisterComponent implements OnInit { password: '', passwordConfirm: '', privacyPolicy: false, + send: false, }; registrationSuccess: boolean = false; @@ -49,11 +50,13 @@ export class RegisterComponent implements OnInit { password: this.authData.password, }; try { + this.authData.send = true; await this.authService.register(body); ngForm.resetForm(); this.registrationSuccess = true; this.errorService.clearError(); } catch (error) { + this.authData.send = false; this.errorService.handleError(error); } } diff --git a/frontend/src/app/components/auth/verify-email/verify-email.component.ts b/frontend/src/app/components/auth/verify-email/verify-email.component.ts index 29d79b3..00d0ef6 100644 --- a/frontend/src/app/components/auth/verify-email/verify-email.component.ts +++ b/frontend/src/app/components/auth/verify-email/verify-email.component.ts @@ -18,6 +18,7 @@ export class VerifyEmailComponent { authData = { mail: '', token: '', + send: false, }; constructor( @@ -40,10 +41,12 @@ export class VerifyEmailComponent { token: this.authData.token, }; try { + this.authData.send = true; await this.authService.verifyEmail(body); this.verified = true; this.errorService.clearError(); } catch (error) { + this.authData.send = false; this.verified = false; this.errorService.handleError(error); }