WIP: Google login
This commit is contained in:
@@ -1,10 +1,43 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { GoogleLoginProvider, SocialAuthService } from '@abacritt/angularx-social-login';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-login-page',
|
||||
templateUrl: './login-page.component.html',
|
||||
styleUrls: ['./login-page.component.scss']
|
||||
})
|
||||
export class LoginPageComponent {
|
||||
export class LoginPageComponent implements OnInit {
|
||||
constructor(
|
||||
private authService: SocialAuthService
|
||||
) {}
|
||||
|
||||
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);
|
||||
const responsePayload = decodeJwtResponse(response.credential);
|
||||
}
|
||||
|
||||
login() {
|
||||
this.authService.signIn(GoogleLoginProvider.PROVIDER_ID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user