Files
DiunaBI/Frontend/src/app/components/login-page/login-page.component.ts

44 lines
1.2 KiB
TypeScript
Raw Normal View History

2022-12-05 14:20:34 +01:00
import { GoogleLoginProvider, SocialAuthService } from '@abacritt/angularx-social-login';
import { Component, OnInit } from '@angular/core';
2022-11-30 10:44:58 +01:00
@Component({
selector: 'app-login-page',
templateUrl: './login-page.component.html',
styleUrls: ['./login-page.component.scss']
})
2022-12-05 14:20:34 +01:00
export class LoginPageComponent implements OnInit {
constructor(
private authService: SocialAuthService
) {}
2022-11-30 10:44:58 +01:00
2022-12-05 14:20:34 +01:00
ngOnInit(): void {
// @ts-ignore
google.accounts.id.initialize({
client_id: "107631825312-bkfe438ehr9k9ecb2h76g802tj6advma.apps.googleusercontent.com",
callback: this.handleCredentialResponse.bind(this),
auto_select: false,
cancel_on_tap_outside: true,
});
// @ts-ignore
google.accounts.id.renderButton(
// @ts-ignore
document.getElementById("google-button"),
{ theme: "outline", size: "large", width: "100%" }
);
// @ts-ignore
google.accounts.id.prompt((notification: PromptMomentNotification) => { });
}
async handleCredentialResponse(response: any) {
// Here will be your response from Google.
console.log(response);
2022-12-05 14:34:48 +01:00
// const responsePayload = decodeJwtResponse(response.credential);
2022-12-05 14:20:34 +01:00
}
login() {
this.authService.signIn(GoogleLoginProvider.PROVIDER_ID);
}
2022-11-30 10:44:58 +01:00
}
2022-12-05 14:20:34 +01:00