From 99098dd9cfdaca3aa2b8f49e49a48e95ca895bfb Mon Sep 17 00:00:00 2001 From: Chneemann Date: Tue, 22 Apr 2025 13:19:32 +0200 Subject: [PATCH] fix: minor bugfixes in the authentication process --- backend/auth_app/views.py | 5 ++--- .../auth/forgot-password/forgot-password.component.ts | 4 ++-- .../components/auth/landing-page/landing-page.component.ts | 4 ++-- .../src/app/components/auth/register/register.component.ts | 2 +- .../components/auth/verify-email/verify-email.component.ts | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/backend/auth_app/views.py b/backend/auth_app/views.py index 358419f..873a009 100644 --- a/backend/auth_app/views.py +++ b/backend/auth_app/views.py @@ -75,7 +75,7 @@ class RegisterView(APIView): message = EmailMultiAlternatives( subject='Confirm your email', - body=strip_tags(html_body), # Plain text fallback + body=strip_tags(html_body), from_email=settings.DEFAULT_FROM_EMAIL, to=[user.email] ) @@ -153,8 +153,7 @@ class ChangePasswordView(APIView): class AuthView(ObtainAuthToken): authentication_classes = [authentication.TokenAuthentication] - permission_classes = [permissions.IsAuthenticated] - + def get(self, request): if request.user.is_authenticated: return Response(request.user.id, status=status.HTTP_200_OK) 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 409f54c..2577489 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 @@ -68,7 +68,7 @@ export class ForgotPasswordComponent implements OnInit { async verifyEmail() { const body = { - email: this.authData.mail, + email: this.authData.mail.toLowerCase(), }; try { this.authData.send = true; @@ -84,7 +84,7 @@ export class ForgotPasswordComponent implements OnInit { async changePassword() { const body = { - email: this.authData.mail, + email: this.authData.mail.toLowerCase(), token: this.authData.token, new_password: this.authData.password, }; diff --git a/frontend/src/app/components/auth/landing-page/landing-page.component.ts b/frontend/src/app/components/auth/landing-page/landing-page.component.ts index a9c5b03..732b510 100644 --- a/frontend/src/app/components/auth/landing-page/landing-page.component.ts +++ b/frontend/src/app/components/auth/landing-page/landing-page.component.ts @@ -40,12 +40,12 @@ export class LandingPageComponent { async checkDuplicatesEmail() { const body = { - email: this.authData.mail, + email: this.authData.mail.toLowerCase(), }; try { this.authData.send = true; await this.authService.checkAuthUserMail(body); - const queryParams = { mail: this.authData.mail }; + const queryParams = { mail: this.authData.mail.toLowerCase() }; this.router.navigate(['/register'], { queryParams }); this.errorService.clearError(); } catch (error) { diff --git a/frontend/src/app/components/auth/register/register.component.ts b/frontend/src/app/components/auth/register/register.component.ts index dd1cb52..7dd9bef 100644 --- a/frontend/src/app/components/auth/register/register.component.ts +++ b/frontend/src/app/components/auth/register/register.component.ts @@ -44,7 +44,7 @@ export class RegisterComponent implements OnInit { async onSubmit(ngForm: NgForm) { if (ngForm.submitted && ngForm.form.valid) { const body = { - email: this.authData.mail, + email: this.authData.mail.toLowerCase(), username: this.authData.mail.split('@')[0], password: this.authData.password, }; 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 00d0ef6..6f09858 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 @@ -37,7 +37,7 @@ export class VerifyEmailComponent { async verifyEmail() { const body = { - email: this.authData.mail, + email: this.authData.mail.toLowerCase(), token: this.authData.token, }; try {