This commit is contained in:
Nikolaos Laskaris 2017-11-01 19:23:00 +02:00
parent 5932ceea51
commit 775e8f0d31
2 changed files with 0 additions and 142 deletions

View File

@ -1,55 +0,0 @@
<html lang="en">
<head>
</head>
<body>
<!-- <div class="g-signin2" data-onsuccess="onSignIn"></div> -->
<div class="container">
<form class="form-signin">
<h2 class="form-signin-heading">Please sign in</h2>
<label for="inputEmail" class="sr-only">Email address</label>
<input type="email" id="inputEmail" class="form-control" placeholder="Email address" required autofocus>
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" id="inputPassword" class="form-control" placeholder="Password" required>
<div class="checkbox">
<label>
<input type="checkbox" value="remember-me"> Remember me
</label>
</div>
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
</form>
<div class="form-signin">
<div class="col-md-6">
<h5>Sign in with</h5>
</div>
<!-- <google-signin [clientId]="myClientId" (googleSignInSuccess)="onGoogleSignInSuccess($event)"></google-signin> -->
<div class="g-signin2" id="googleBtn"></div>
</div>
</div>
<!-- /container -->
<!-- <div class="container">
<div class="col-md-3 text-center">
<h4>Please Sign in with Google Account</h4>
</div>
<div class="col-md-3 text-center">
<div>
<google-signin [clientId]="myClientId" (googleSignInSuccess)="onGoogleSignInSuccess($event)"></google-signin>
</div>
</div>
</div> -->
<!-- <button routerLink="/dynamic-form">Go to form</button>
<button routerLink="/projects">Go to projects</button> trial for routing -->
<!-- <a href="#" onclick="signOut();">Sign out</a> -->
</body>
</html>

View File

@ -1,87 +0,0 @@
import { Component, OnInit, NgZone, AfterViewInit, ElementRef } from '@angular/core';
import { GoogleSignInSuccess } from 'angular-google-signin';
import { Router, ActivatedRoute } from '@angular/router';
import { TokenService, TokenProvider } from '../services/login/token.service';
@Component({
selector: 'login-page',
templateUrl: './login-page.html',
providers: []
})
export class LoginComponent implements OnInit, AfterViewInit {
returnUrl: string;
token: any;
constructor(
private route: ActivatedRoute,
private router: Router,
private ngZone: NgZone,
private tokenService: TokenService,
private element: ElementRef
) {
}
ngOnInit() {
// reset login status
//this.authenticationService.logout();
// get return url from route parameters or default to '/'
//this.returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/';
}
//private myClientId: string = '524432312250-vhgidft856v8qftsc81kls4c74v87d8o.apps.googleusercontent.com';
private myClientId: string = '1010962018903-glegmqudqtl1lub0150vacopbu06lgsg.apps.googleusercontent.com';
public auth2: any;
private scope = [
'profile',
'email'
].join(' ');
public googleInit() {
gapi.load('auth2', () => {
this.auth2 = gapi.auth2.init({
client_id: this.myClientId,
cookie_policy: 'single_host_origin',
scope: this.scope
});
var buttonElement = this.element.nativeElement.querySelector('#googleBtn');
this.attachSignin(buttonElement);
});
}
public attachSignin(element) {
this.auth2.attachClickHandler(element, {},
(googleUser) => {
this.token = googleUser.getAuthResponse().id_token;
let profile = googleUser.getBasicProfile();
this.tokenService.setLoggedIn(true);
this.tokenService.setToken(this.token);
this.tokenService.setProvider(TokenProvider.google);
this.tokenService.setUsername(profile.getName());
this.tokenService.setEmail(profile.getEmail());
this.ngZone.run(() => this.router.navigateByUrl('tabs'));
window.location.reload();
}, function (error) {
console.log(JSON.stringify(error, undefined, 2));
});
}
ngAfterViewInit() {
this.googleInit();
}
}