Login refactor
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
import { Component, NgZone, OnInit } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import jwt_decode from "jwt-decode";
|
||||
import { AuthService } from 'src/app/auth/auth.service';
|
||||
import { User } from 'src/app/models/user.model';
|
||||
import { NotificationsService } from 'src/app/services/notifications.service';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
@@ -54,25 +52,16 @@ export class LoginViewComponent implements OnInit {
|
||||
// @ts-ignore
|
||||
google.accounts.id.prompt();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
async handleCredentialResponse(response: any) {
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const responsePayload: any = jwt_decode(response.credential);
|
||||
|
||||
this.auth$.user = new User({
|
||||
googleCredentials: response.credential,
|
||||
userName: `${responsePayload.given_name} ${responsePayload.family_name}`,
|
||||
email: responsePayload.email,
|
||||
avatar: responsePayload.picture
|
||||
});
|
||||
this.auth$.retrieveUserFromCredentials(response.credential);
|
||||
this.auth$.webCredentials = response.credential;
|
||||
this.ngZone$.run(() => {
|
||||
this.loading = true;
|
||||
});
|
||||
this.auth$.googleCredential = response.credential;
|
||||
await this.auth$.getAPIToken();
|
||||
this.ngZone$.run(() => {
|
||||
this.router$.navigate(['/app']);
|
||||
|
||||
Reference in New Issue
Block a user