Login page lifecycle fix

This commit is contained in:
2023-01-08 17:33:22 +01:00
parent 80f09b6f18
commit c81a8297b7
2 changed files with 25 additions and 13 deletions

View File

@@ -59,7 +59,10 @@ export class LoginPageComponent implements OnInit {
email: responsePayload.email,
avatar: responsePayload.picture
});
this.loading = true;
this.ngZone$.run(() => {
this.loading = true;
});
await this.sleep(2500);
await this.auth$.getAPIToken(response.credential);
this.ngZone$.run(() => {
this.router$.navigate(['/app']);
@@ -67,21 +70,32 @@ export class LoginPageComponent implements OnInit {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (e: any) {
console.error('handleCredentialResponse', e);
this.loading = false;
this.ngZone$.run(() => {
this.loading = false;
});
if (e.status === 401) {
this.notifications$.add({
text: "Użytkownik nie istnieje w bazie danych aplikacji DiunaBI.",
duration: 2500
this.ngZone$.run(() => {
this.notifications$.add({
text: "Użytkownik nie istnieje w bazie danych aplikacji DiunaBI.",
btn: "OK",
duration: 15000
});
});
} else {
this.notifications$.add({
text: "Błąd połączenia z serwerem. Skontaktuj się z administratorem.",
duration: 2500
this.ngZone$.run(() => {
this.notifications$.add({
text: "Błąd połączenia z serwerem. Skontaktuj się z administratorem.",
btn: "OK",
duration: 15000
});
});
}
} finally {
this.loading = false;
}
}
sleep(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms));
}
}

View File

@@ -6,12 +6,10 @@ mat-card {
cursor: pointer;
}
.text {
display: inline-block;
width: 70%;
float: left;
}
.btn {
display: inline-block;
width: 30%;
text-align: right;
float: right;
color: red;
margin-left: 5px;
}