From ccc7784489736eb3da5d23e58b12343c90aec149 Mon Sep 17 00:00:00 2001 From: Paola Date: Tue, 6 Jul 2021 20:49:15 -0600 Subject: [PATCH 1/3] Remover procesos en service Google --- .../login/usuario-google-log-in.service.ts | 25 +------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/src/main/webapp/app/login/usuario-google-log-in.service.ts b/src/main/webapp/app/login/usuario-google-log-in.service.ts index 5d6818c..a6c3739 100644 --- a/src/main/webapp/app/login/usuario-google-log-in.service.ts +++ b/src/main/webapp/app/login/usuario-google-log-in.service.ts @@ -5,28 +5,5 @@ import { Observable, ReplaySubject } from 'rxjs'; providedIn: 'root', }) export class UsuarioGoogleLogInService { - constructor(private auth2: gapi.auth2.GoogleAuth, private subject: ReplaySubject) { - gapi.load('auth2', () => { - this.auth2 = gapi.auth2.init({ - client_id: '178178891217-b517thad8f15d4at2vk2410v7a09dcvt.apps.googleusercontent.com', - }); - }); - } - - public sigIn() { - this.auth2 - .signIn({ - // - }) - .then(user => { - this.subject.next(user); - }) - .catch(() => { - this.subject.next(); //NULL - }); - } - - public observable(): Observable { - return this.subject.asObservable(); - } + constructor() {} } From 08a1cc5c32faa60166709f8327443e2e05a2fdfd Mon Sep 17 00:00:00 2001 From: Paola Date: Tue, 6 Jul 2021 20:49:15 -0600 Subject: [PATCH 2/3] Agregar servicio de loggeo Google --- src/main/webapp/app/login/login.component.ts | 17 +++++++++++-- .../login/usuario-google-log-in.service.ts | 25 +------------------ 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/src/main/webapp/app/login/login.component.ts b/src/main/webapp/app/login/login.component.ts index 765e35e..ae9a36a 100644 --- a/src/main/webapp/app/login/login.component.ts +++ b/src/main/webapp/app/login/login.component.ts @@ -4,7 +4,7 @@ import { Router } from '@angular/router'; import { LoginService } from 'app/login/login.service'; import { AccountService } from 'app/core/auth/account.service'; -import { SocialAuthService } from 'angularx-social-login'; +import { SocialAuthService, SocialUser } from 'angularx-social-login'; import { GoogleLoginProvider } from 'angularx-social-login'; @Component({ @@ -24,6 +24,9 @@ export class LoginComponent implements OnInit, AfterViewInit { rememberMe: [false], }); + user: SocialUser = new SocialUser(); + loggedIn: boolean = false; + constructor( private accountService: AccountService, private loginService: LoginService, @@ -33,7 +36,12 @@ export class LoginComponent implements OnInit, AfterViewInit { ) {} ngOnInit(): void { - //console.log("Google ID: "+ GoogleLoginProvider.PROVIDER_ID) + //Servicio para verificar si el usuario se encuentra loggeado + this.authService.authState.subscribe(user => { + this.user = user; + this.loggedIn = user != null; + }); + // if already authenticated then navigate to home page this.accountService.identity().subscribe(() => { if (this.accountService.isAuthenticated()) { @@ -46,10 +54,15 @@ export class LoginComponent implements OnInit, AfterViewInit { this.username.nativeElement.focus(); } + //Inicio Google signInWithGoogle(): void { this.authService.signIn(GoogleLoginProvider.PROVIDER_ID); } + refreshToken(): void { + this.authService.refreshAuthToken(GoogleLoginProvider.PROVIDER_ID); + } + login(): void { this.loginService .login({ diff --git a/src/main/webapp/app/login/usuario-google-log-in.service.ts b/src/main/webapp/app/login/usuario-google-log-in.service.ts index 5d6818c..a6c3739 100644 --- a/src/main/webapp/app/login/usuario-google-log-in.service.ts +++ b/src/main/webapp/app/login/usuario-google-log-in.service.ts @@ -5,28 +5,5 @@ import { Observable, ReplaySubject } from 'rxjs'; providedIn: 'root', }) export class UsuarioGoogleLogInService { - constructor(private auth2: gapi.auth2.GoogleAuth, private subject: ReplaySubject) { - gapi.load('auth2', () => { - this.auth2 = gapi.auth2.init({ - client_id: '178178891217-b517thad8f15d4at2vk2410v7a09dcvt.apps.googleusercontent.com', - }); - }); - } - - public sigIn() { - this.auth2 - .signIn({ - // - }) - .then(user => { - this.subject.next(user); - }) - .catch(() => { - this.subject.next(); //NULL - }); - } - - public observable(): Observable { - return this.subject.asObservable(); - } + constructor() {} } From 7da71d876917484b1039287aba2f7e24c222143c Mon Sep 17 00:00:00 2001 From: Paola Date: Sat, 10 Jul 2021 20:02:17 -0600 Subject: [PATCH 3/3] arreglo de estilos GoogleLogIn --- .../webapp/app/login/login.component.html | 11 +++- .../webapp/app/login/login.component.scss | 53 +++++++++++++++++++ src/main/webapp/app/login/login.component.ts | 1 + 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/src/main/webapp/app/login/login.component.html b/src/main/webapp/app/login/login.component.html index 60fbfa0..0e533ea 100644 --- a/src/main/webapp/app/login/login.component.html +++ b/src/main/webapp/app/login/login.component.html @@ -129,11 +129,18 @@ -
+
+
+ +
+ +
+ +
diff --git a/src/main/webapp/app/login/login.component.scss b/src/main/webapp/app/login/login.component.scss index 192b03b..3ae8435 100644 --- a/src/main/webapp/app/login/login.component.scss +++ b/src/main/webapp/app/login/login.component.scss @@ -1,3 +1,56 @@ body { background-color: #f2f2f2 !important; } + +$white: #fff; +$google-blue: #4285f4; +$button-active-blue: #1669f2; + +.google-btn { + width: 184px; + height: 42px; + background-color: $google-blue !important; + border-radius: 2px; + box-shadow: 0 3px 4px 0 rgba(0, 0, 0, 0.25); + .google-icon-wrapper { + position: absolute; + margin-top: 1px; + margin-left: 1px; + width: 40px; + height: 40px; + border-radius: 2px; + background-color: $white; + } + .google-icon { + position: absolute; + margin-top: 11px; + margin-left: 11px; + width: 18px; + height: 18px; + } + .btn-text { + float: right; + margin: 5px 5px 0px 0px; + color: $white; + font-size: 14px; + letter-spacing: 0.2px; + font-family: 'Roboto'; + background-color: $google-blue; + width: 135px; + height: 30px; + padding: 6px 6px 7px 6px; + border: $google-blue; + } + &:hover { + box-shadow: 0 0 6px $google-blue !important; + } + &:active { + background: $button-active-blue !important; + } + + .google-div { + margin-left: 150px !important; + } +} + +@import url(https://fonts.googleapis.com/css?family=Roboto:500); diff --git a/src/main/webapp/app/login/login.component.ts b/src/main/webapp/app/login/login.component.ts index 0176be5..4d2abbd 100644 --- a/src/main/webapp/app/login/login.component.ts +++ b/src/main/webapp/app/login/login.component.ts @@ -91,6 +91,7 @@ export class LoginComponent implements OnInit, AfterViewInit { () => { this.authenticationError = false; if (!this.router.getCurrentNavigation()) { + window.localStorage.setItem('IsGoogle', 'true'); // There were no routing during login (eg from navigationToStoredUrl) this.router.navigate(['']); }