added guest login
This commit is contained in:
parent
3475c61bf3
commit
e3d02d2866
4 changed files with 49 additions and 8 deletions
|
|
@ -76,14 +76,22 @@
|
|||
<span class="checkmark"></span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<app-btn-large
|
||||
[value]="'Log in'"
|
||||
[disabled]="
|
||||
!authData.mail ||
|
||||
(!isUserEmailValid(authData.mail) && authData.mail.length > 0) ||
|
||||
!password.valid
|
||||
!password.valid ||
|
||||
authData.guestLogin
|
||||
"
|
||||
></app-btn-large>
|
||||
<app-btn-large
|
||||
[value]="'Guest Log in'"
|
||||
[disabled]="authData.guestLogin"
|
||||
(click)="guestLogin()"
|
||||
></app-btn-large>
|
||||
</div>
|
||||
</form>
|
||||
<div class="footer">
|
||||
<a routerLink="/forgot-password">Forgot password?</a>
|
||||
|
|
|
|||
|
|
@ -12,6 +12,13 @@ section {
|
|||
position: relative;
|
||||
}
|
||||
|
||||
.buttons {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
.footer {
|
||||
margin-top: 36px;
|
||||
a {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import { AuthService } from '../../../services/auth.service';
|
|||
import { ErrorService } from '../../../services/error.service';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { environment } from '../../../environments/environment';
|
||||
|
||||
@Component({
|
||||
selector: 'app-login',
|
||||
|
|
@ -20,6 +21,7 @@ export class LoginComponent {
|
|||
password: '',
|
||||
checkbox: false,
|
||||
send: false,
|
||||
guestLogin: false,
|
||||
};
|
||||
|
||||
showPassword: boolean = false;
|
||||
|
|
@ -35,6 +37,26 @@ export class LoginComponent {
|
|||
return emailRegex.test(emailValue);
|
||||
}
|
||||
|
||||
async guestLogin() {
|
||||
this.authData.mail = environment.guestMail;
|
||||
this.authData.password = environment.guestPassword;
|
||||
this.authData.guestLogin = true;
|
||||
const body = {
|
||||
email: environment.guestMail,
|
||||
password: environment.guestPassword,
|
||||
};
|
||||
try {
|
||||
await this.authService.login(body, this.authData.checkbox);
|
||||
this.authData.mail = '';
|
||||
this.authData.password = '';
|
||||
this.authData.guestLogin = false;
|
||||
this.router.navigate(['/browse/']);
|
||||
this.errorService.clearError();
|
||||
} catch (error) {
|
||||
this.errorService.handleError(error);
|
||||
}
|
||||
}
|
||||
|
||||
async onSubmit(ngForm: NgForm) {
|
||||
if (ngForm.submitted && ngForm.form.valid) {
|
||||
const body = {
|
||||
|
|
|
|||
|
|
@ -4,4 +4,8 @@ export const environment = {
|
|||
|
||||
// Live
|
||||
// baseUrl: 'https://videoflix-django.andre-kempf.com',
|
||||
|
||||
// Guest account
|
||||
guestMail: 'guest@example.com',
|
||||
guestPassword: 'guest@example.com',
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue