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>
|
<span class="checkmark"></span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="buttons">
|
||||||
<app-btn-large
|
<app-btn-large
|
||||||
[value]="'Log in'"
|
[value]="'Log in'"
|
||||||
[disabled]="
|
[disabled]="
|
||||||
!authData.mail ||
|
!authData.mail ||
|
||||||
(!isUserEmailValid(authData.mail) && authData.mail.length > 0) ||
|
(!isUserEmailValid(authData.mail) && authData.mail.length > 0) ||
|
||||||
!password.valid
|
!password.valid ||
|
||||||
|
authData.guestLogin
|
||||||
"
|
"
|
||||||
></app-btn-large>
|
></app-btn-large>
|
||||||
|
<app-btn-large
|
||||||
|
[value]="'Guest Log in'"
|
||||||
|
[disabled]="authData.guestLogin"
|
||||||
|
(click)="guestLogin()"
|
||||||
|
></app-btn-large>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<a routerLink="/forgot-password">Forgot password?</a>
|
<a routerLink="/forgot-password">Forgot password?</a>
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,13 @@ section {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.buttons {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
width: 100%;
|
||||||
|
gap: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
.footer {
|
.footer {
|
||||||
margin-top: 36px;
|
margin-top: 36px;
|
||||||
a {
|
a {
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import { AuthService } from '../../../services/auth.service';
|
||||||
import { ErrorService } from '../../../services/error.service';
|
import { ErrorService } from '../../../services/error.service';
|
||||||
import { HttpErrorResponse } from '@angular/common/http';
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { environment } from '../../../environments/environment';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-login',
|
selector: 'app-login',
|
||||||
|
|
@ -20,6 +21,7 @@ export class LoginComponent {
|
||||||
password: '',
|
password: '',
|
||||||
checkbox: false,
|
checkbox: false,
|
||||||
send: false,
|
send: false,
|
||||||
|
guestLogin: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
showPassword: boolean = false;
|
showPassword: boolean = false;
|
||||||
|
|
@ -35,6 +37,26 @@ export class LoginComponent {
|
||||||
return emailRegex.test(emailValue);
|
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) {
|
async onSubmit(ngForm: NgForm) {
|
||||||
if (ngForm.submitted && ngForm.form.valid) {
|
if (ngForm.submitted && ngForm.form.valid) {
|
||||||
const body = {
|
const body = {
|
||||||
|
|
|
||||||
|
|
@ -4,4 +4,8 @@ export const environment = {
|
||||||
|
|
||||||
// Live
|
// Live
|
||||||
// baseUrl: 'https://videoflix-django.andre-kempf.com',
|
// baseUrl: 'https://videoflix-django.andre-kempf.com',
|
||||||
|
|
||||||
|
// Guest account
|
||||||
|
guestMail: 'guest@example.com',
|
||||||
|
guestPassword: 'guest@example.com',
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue