feat: add "Remember Me" checkbox in LoginComponent

This commit is contained in:
Chneemann 2025-03-23 22:05:06 +01:00
parent d97579b97e
commit 39e03d2fab
5 changed files with 57 additions and 5 deletions

View file

@ -81,6 +81,18 @@
<p>{{ "login.errorPassword1" | translate }}</p> <p>{{ "login.errorPassword1" | translate }}</p>
} }
</div> </div>
<div class="checkbox">
<label class="container">
<input
type="checkbox"
id="checkbox"
name="checkbox"
#checkbox
[(ngModel)]="checkboxRememberMe"
/>
{{ "login.rememberMe" | translate }}
</label>
</div>
<div class="forgot-pw"> <div class="forgot-pw">
<a routerLink="/forgot-pw">{{ <a routerLink="/forgot-pw">{{
"login.forgotPassword" | translate "login.forgotPassword" | translate

View file

@ -87,7 +87,7 @@ section {
} }
.forgot-pw { .forgot-pw {
padding-bottom: 24px; margin: 12px 0;
a { a {
text-align: center; text-align: center;
font-size: 16px; font-size: 16px;
@ -104,6 +104,41 @@ section {
} }
} }
// Checkbox
.checkbox {
display: flex;
justify-content: flex-start;
align-items: center;
width: 100%;
margin-bottom: 12px;
}
.container {
display: flex;
align-items: center;
font-size: 16px;
color: var(--gray);
cursor: pointer;
&:hover {
color: var(--light-blue);
font-weight: 600;
}
}
input[type="checkbox"] {
width: 20px;
height: 20px;
margin-right: 8px;
accent-color: var(--light-blue);
cursor: pointer;
transition: all 0.2s ease;
}
input[type="checkbox"]:hover {
transform: scale(1.1);
}
/*------------- RESPONSIVE -------------*/ /*------------- RESPONSIVE -------------*/
@media (max-height: 800px) { @media (max-height: 800px) {

View file

@ -31,6 +31,7 @@ import { AuthService } from '../../services/auth.service';
}) })
export class LoginComponent { export class LoginComponent {
isPasswordIconVisible: boolean = true; isPasswordIconVisible: boolean = true;
checkboxRememberMe: boolean = false;
loginData = { loginData = {
email: '', email: '',
@ -65,7 +66,7 @@ export class LoginComponent {
this.sharedService.isBtnDisabled = true; this.sharedService.isBtnDisabled = true;
if (ngForm.submitted && ngForm.form.valid) { if (ngForm.submitted && ngForm.form.valid) {
try { try {
await this.authService.login(this.loginData, true); await this.authService.login(this.loginData, this.checkboxRememberMe);
this.router.navigate(['/summary']); this.router.navigate(['/summary']);
} catch (error) { } catch (error) {
this.sharedService.isBtnDisabled = false; this.sharedService.isBtnDisabled = false;
@ -81,10 +82,12 @@ export class LoginComponent {
this.onSubmit({ submitted: true, form: { valid: true } } as NgForm); this.onSubmit({ submitted: true, form: { valid: true } } as NgForm);
} }
/*
googleLogin() { googleLogin() {
this.sharedService.isBtnDisabled = true; this.sharedService.isBtnDisabled = true;
this.loginService.googleLogin(); this.loginService.googleLogin();
} }
*/
checkIfUserEmailIsValid(emailValue: string) { checkIfUserEmailIsValid(emailValue: string) {
const emailRegex = /^[\w.%+-]+@[\w.-]+\.[a-zA-Z]{2,}$/; const emailRegex = /^[\w.%+-]+@[\w.-]+\.[a-zA-Z]{2,}$/;

View file

@ -12,7 +12,8 @@
"errorPassword0": "Sie müssen ein Passwort eingeben!", "errorPassword0": "Sie müssen ein Passwort eingeben!",
"errorPassword1": "Das Passwort passt nicht zur E-Mail-Adresse!", "errorPassword1": "Das Passwort passt nicht zur E-Mail-Adresse!",
"loginDialog0": "Einloggen", "loginDialog0": "Einloggen",
"loginDialog1": "Bitte warten..." "loginDialog1": "Bitte warten...",
"rememberMe": "Eingeloggt bleiben"
}, },
"forgotPW": { "forgotPW": {
"forgot": "Passwort zurücksetzen", "forgot": "Passwort zurücksetzen",

View file

@ -12,7 +12,8 @@
"errorPassword0": "You must enter a password!", "errorPassword0": "You must enter a password!",
"errorPassword1": "The password does not match the email address!", "errorPassword1": "The password does not match the email address!",
"loginDialog0": "Logging in", "loginDialog0": "Logging in",
"loginDialog1": "Please wait..." "loginDialog1": "Please wait...",
"rememberMe": "Remember me"
}, },
"forgotPW": { "forgotPW": {
"forgot": "Reset Password", "forgot": "Reset Password",