WIP: Google login

This commit is contained in:
2022-12-05 14:20:34 +01:00
parent abb1c29ac8
commit fb823e06cd
12 changed files with 156 additions and 32 deletions

View File

@@ -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);
}
}