Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public auth2: any;
- public googleInit() {
- gapi.load('auth2', () => {
- this.auth2 = gapi.auth2.init({
- client_id: 'my-client id',
- scope: 'profile email'
- });
- this.attachSignin(document.getElementById('googleSignIn'));
- });
- }
- public attachSignin(element:any) {
- this.auth2.attachClickHandler(element, {},
- (googleUser:any) => {
- let profile = googleUser.getBasicProfile();
- this.login(profile.getEmail(),"", 'S')/*Calling login function*/
- },
- (error:any) => {
- //alert(JSON.stringify(error, undefined, 2));
- });
- }
- ngAfterViewInit(){
- this.googleInit();
- }
- login(userId: string, password: string, option: string) {
- this.authenticationService.login(userId,password,option)
- .subscribe(
- data => {
- if (data.responseStatus) {
- this.isSignBtnDisbld=false;
- this.router.navigate(['/home']);
- } else {
- alert(data.errorMsg);
- }
- },
- error => {
- alert("Server Error");
- });
- }
Add Comment
Please, Sign In to add comment