diff --git a/package-lock.json b/package-lock.json index 250092c..0fb0280 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,7 +1,7 @@ { "name": "data-survey", "version": "0.0.1-SNAPSHOT", - "lockfileVersion": 2, + "lockfileVersion": 1, "requires": true, "packages": { "": { @@ -30320,6 +30320,19 @@ "@types/node": "*" } }, + "@types/gapi": { + "version": "0.0.39", + "resolved": "https://registry.npmjs.org/@types/gapi/-/gapi-0.0.39.tgz", + "integrity": "sha512-R1TZeZbvvbIC60DBJMhuOEivQHzOQtzl3uMDOOENTYQTSSDB6oEMpJo8HVPOTWivdUTbyEcB5qQOVr/JCKRlCQ==" + }, + "@types/gapi.auth2": { + "version": "0.0.54", + "resolved": "https://registry.npmjs.org/@types/gapi.auth2/-/gapi.auth2-0.0.54.tgz", + "integrity": "sha512-4HEphaKsGndb9+tnd2PBBmxloaij04iYXVsjgHpFxqbPFt5Le6pasoh5g5BEtwp/YEm9xDbzssp44BYR2/7RcQ==", + "requires": { + "@types/gapi": "*" + } + }, "@types/glob": { "version": "7.1.3", "resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.1.3.tgz", @@ -30984,6 +30997,14 @@ "integrity": "sha1-l6ERlkmyEa0zaR2fn0hqjsn74KM=", "dev": true }, + "angularx-social-login": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/angularx-social-login/-/angularx-social-login-4.0.1.tgz", + "integrity": "sha512-dL65y0HXlKd8hhuH70/FFTxWsndEBU5DX2I1x7AcJ1ZAYpU6LPtQMbnzy10eSOcWZNeZX8XzaRaIbc4P+GjmvA==", + "requires": { + "tslib": "^2.0.0" + } + }, "ansi-colors": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", @@ -31629,16 +31650,6 @@ "integrity": "sha512-MkUl3szxXolQ2scI1PM14WOT951KnaTNJ0eMKg7WzOI4kvSxyNo/Cygx4LOBNhwyINhAuSQpJW1rYD9aBSxGaw==", "dev": true }, - "bindings": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", - "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", - "dev": true, - "optional": true, - "requires": { - "file-uri-to-path": "1.0.0" - } - }, "bl": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", @@ -35222,13 +35233,6 @@ "flat-cache": "^3.0.4" } }, - "file-uri-to-path": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", - "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", - "dev": true, - "optional": true - }, "filelist": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.2.tgz", @@ -40208,13 +40212,6 @@ "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", "dev": true }, - "nan": { - "version": "2.14.2", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.2.tgz", - "integrity": "sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ==", - "dev": true, - "optional": true - }, "nanoid": { "version": "3.1.23", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.23.tgz", @@ -45121,23 +45118,6 @@ "readable-stream": "^3.0.6" } }, - "string_decoder": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "dev": true, - "requires": { - "safe-buffer": "~5.2.0" - }, - "dependencies": { - "safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "dev": true - } - } - }, "string-argv": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.1.tgz", @@ -45164,6 +45144,23 @@ "strip-ansi": "^6.0.0" } }, + "string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dev": true, + "requires": { + "safe-buffer": "~5.2.0" + }, + "dependencies": { + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true + } + } + }, "stringify-object": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/stringify-object/-/stringify-object-3.3.0.tgz", @@ -46906,11 +46903,7 @@ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", "dev": true, - "optional": true, - "requires": { - "bindings": "^1.5.0", - "nan": "^2.12.1" - } + "optional": true }, "glob-parent": { "version": "3.1.0", @@ -47148,15 +47141,6 @@ "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", "dev": true }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - }, "string-width": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", @@ -47185,6 +47169,15 @@ } } }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + }, "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", diff --git a/package.json b/package.json index 8cb4b47..b6ca8a7 100644 --- a/package.json +++ b/package.json @@ -80,6 +80,8 @@ "@ng-bootstrap/ng-bootstrap": "9.1.3", "@ngx-translate/core": "13.0.0", "@ngx-translate/http-loader": "6.0.0", + "@types/gapi.auth2": "0.0.54", + "angularx-social-login": "^4.0.1", "bootstrap": "4.6.0", "dayjs": "1.10.5", "ngx-infinite-scroll": "10.0.1", diff --git a/src/main/java/org/datasurvey/config/ApplicationProperties.java b/src/main/java/org/datasurvey/config/ApplicationProperties.java index 86c8468..2481b0f 100644 --- a/src/main/java/org/datasurvey/config/ApplicationProperties.java +++ b/src/main/java/org/datasurvey/config/ApplicationProperties.java @@ -8,5 +8,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties; * Properties are configured in the {@code application.yml} file. * See {@link tech.jhipster.config.JHipsterProperties} for a good example. */ + @ConfigurationProperties(prefix = "application", ignoreUnknownFields = false) public class ApplicationProperties {} diff --git a/src/main/java/org/datasurvey/config/SecurityConfiguration.java b/src/main/java/org/datasurvey/config/SecurityConfiguration.java index 1661950..f2e6e1b 100644 --- a/src/main/java/org/datasurvey/config/SecurityConfiguration.java +++ b/src/main/java/org/datasurvey/config/SecurityConfiguration.java @@ -92,6 +92,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { .antMatchers("/api/account/reset-password/finish").permitAll() .antMatchers("/api/admin/**").hasAuthority(AuthoritiesConstants.ADMIN) .antMatchers("/api/**").authenticated() + .antMatchers("/api/**").permitAll() .antMatchers("/websocket/**").authenticated() .antMatchers("/management/health").permitAll() .antMatchers("/management/health/**").permitAll() diff --git a/src/main/java/org/datasurvey/service/UserService.java b/src/main/java/org/datasurvey/service/UserService.java index e1d8bb5..227c590 100644 --- a/src/main/java/org/datasurvey/service/UserService.java +++ b/src/main/java/org/datasurvey/service/UserService.java @@ -156,7 +156,7 @@ public class UserService { * Modified to register extra user data * name, iconoPerfil, fechaNacimiento, estado, pais */ - public User registerUser(AdminUserDTO userDTO, String password, String name, Integer profileIcon, Integer isAdmin) { + public User registerUser(AdminUserDTO userDTO, String password, String name, Integer profileIcon, Integer isAdmin, Integer isGoogle) { userRepository .findOneByLogin(userDTO.getLogin().toLowerCase()) .ifPresent( @@ -190,7 +190,13 @@ public class UserService { newUser.setImageUrl(userDTO.getImageUrl()); newUser.setLangKey(userDTO.getLangKey()); // new user is not active - newUser.setActivated(false); + + if (isGoogle == 1) { + newUser.setActivated(true); + } else { + newUser.setActivated(false); + } + // new user gets registration key newUser.setActivationKey(RandomUtil.generateActivationKey()); Set authorities = new HashSet<>(); diff --git a/src/main/java/org/datasurvey/web/rest/AccountResource.java b/src/main/java/org/datasurvey/web/rest/AccountResource.java index 493ece3..afb4a0c 100644 --- a/src/main/java/org/datasurvey/web/rest/AccountResource.java +++ b/src/main/java/org/datasurvey/web/rest/AccountResource.java @@ -67,9 +67,13 @@ public class AccountResource { managedUserVM.getPassword(), managedUserVM.getName(), managedUserVM.getProfileIcon(), - managedUserVM.getIsAdmin() + managedUserVM.getIsAdmin(), + managedUserVM.getIsGoogle() ); - mailService.sendActivationEmail(user); + + if (managedUserVM.getIsGoogle() != 1) { + mailService.sendActivationEmail(user); + } } /** diff --git a/src/main/java/org/datasurvey/web/rest/vm/ManagedUserVM.java b/src/main/java/org/datasurvey/web/rest/vm/ManagedUserVM.java index 3d1dc73..5cc7a2b 100644 --- a/src/main/java/org/datasurvey/web/rest/vm/ManagedUserVM.java +++ b/src/main/java/org/datasurvey/web/rest/vm/ManagedUserVM.java @@ -24,6 +24,8 @@ public class ManagedUserVM extends AdminUserDTO { private Integer isAdmin; + private Integer isGoogle; + public ManagedUserVM() { // Empty constructor needed for Jackson. } @@ -60,6 +62,14 @@ public class ManagedUserVM extends AdminUserDTO { this.isAdmin = isAdmin; } + public Integer getIsGoogle() { + return isGoogle; + } + + public void setIsGoogle(Integer isGoogle) { + this.isGoogle = isGoogle; + } + // prettier-ignore @Override public String toString() { diff --git a/src/main/webapp/app/account/register/register.component.spec.ts b/src/main/webapp/app/account/register/register.component.spec.ts index 422a382..d040495 100644 --- a/src/main/webapp/app/account/register/register.component.spec.ts +++ b/src/main/webapp/app/account/register/register.component.spec.ts @@ -65,6 +65,7 @@ describe('Component Tests', () => { name: '', profileIcon: 1, isAdmin: 0, + isGoogle: 0, }); expect(comp.success).toBe(true); expect(comp.errorUserExists).toBe(false); diff --git a/src/main/webapp/app/account/register/register.component.ts b/src/main/webapp/app/account/register/register.component.ts index 24a7542..8d1fa62 100644 --- a/src/main/webapp/app/account/register/register.component.ts +++ b/src/main/webapp/app/account/register/register.component.ts @@ -95,6 +95,7 @@ export class RegisterComponent implements AfterViewInit { name, profileIcon: this.profileIcon, isAdmin: 0, + isGoogle: 0, }) .subscribe( () => (this.success = true), @@ -103,7 +104,7 @@ export class RegisterComponent implements AfterViewInit { } } - private processError(response: HttpErrorResponse): void { + processError(response: HttpErrorResponse): void { if (response.status === 400 && response.error.type === LOGIN_ALREADY_USED_TYPE) { this.errorUserExists = true; } else if (response.status === 400 && response.error.type === EMAIL_ALREADY_USED_TYPE) { diff --git a/src/main/webapp/app/account/register/register.model.ts b/src/main/webapp/app/account/register/register.model.ts index 3a3a97d..18a4688 100644 --- a/src/main/webapp/app/account/register/register.model.ts +++ b/src/main/webapp/app/account/register/register.model.ts @@ -6,6 +6,7 @@ export class Registration { public langKey: string, public name: string, public profileIcon: number, - public isAdmin: number + public isAdmin: number, + public isGoogle: number ) {} } diff --git a/src/main/webapp/app/app.module.ts b/src/main/webapp/app/app.module.ts index c297822..df110cd 100644 --- a/src/main/webapp/app/app.module.ts +++ b/src/main/webapp/app/app.module.ts @@ -17,6 +17,10 @@ import { SharedModule } from 'app/shared/shared.module'; import { AppRoutingModule } from './app-routing.module'; import { HomeModule } from './home/home.module'; import { EntityRoutingModule } from './entities/entity-routing.module'; +import { ReactiveFormsModule } from '@angular/forms'; + +import { SocialLoginModule, SocialAuthServiceConfig } from 'angularx-social-login'; +import { GoogleLoginProvider } from 'angularx-social-login'; // jhipster-needle-angular-add-module-import JHipster will add new module here import { NgbDateDayjsAdapter } from './config/datepicker-adapter'; import { fontAwesomeIcons } from './config/font-awesome-icons'; @@ -37,6 +41,7 @@ import { SidebarComponent } from './layouts/sidebar/sidebar.component'; // jhipster-needle-angular-add-module JHipster will add new module here EntityRoutingModule, AppRoutingModule, + SocialLoginModule, // Set this to true to enable service worker (PWA) ServiceWorkerModule.register('ngsw-worker.js', { enabled: false }), HttpClientModule, @@ -58,6 +63,18 @@ import { SidebarComponent } from './layouts/sidebar/sidebar.component'; { provide: LOCALE_ID, useValue: 'es' }, { provide: NgbDateAdapter, useClass: NgbDateDayjsAdapter }, httpInterceptorProviders, + { + provide: 'SocialAuthServiceConfig', + useValue: { + autoLogin: false, + providers: [ + { + id: GoogleLoginProvider.PROVIDER_ID, + provider: new GoogleLoginProvider('178178891217-b517thad8f15d4at2vk2410v7a09dcvt.apps.googleusercontent.com'), + }, + ], + } as SocialAuthServiceConfig, + }, ], declarations: [MainComponent, NavbarComponent, ErrorComponent, PageRibbonComponent, FooterComponent, SidebarComponent], bootstrap: [MainComponent], diff --git a/src/main/webapp/app/entities/usuario-extra/update/usuario-extra-update.component.spec.ts b/src/main/webapp/app/entities/usuario-extra/update/usuario-extra-update.component.spec.ts index c2e698a..2382221 100644 --- a/src/main/webapp/app/entities/usuario-extra/update/usuario-extra-update.component.spec.ts +++ b/src/main/webapp/app/entities/usuario-extra/update/usuario-extra-update.component.spec.ts @@ -65,6 +65,7 @@ describe('Component Tests', () => { name: '', profileIcon: 1, isAdmin: 1, + isGoogle: 0, }); expect(comp.success).toBe(true); expect(comp.errorUserExists).toBe(false); diff --git a/src/main/webapp/app/entities/usuario-extra/update/usuario-extra-update.component.ts b/src/main/webapp/app/entities/usuario-extra/update/usuario-extra-update.component.ts index f712e2b..65f69de 100644 --- a/src/main/webapp/app/entities/usuario-extra/update/usuario-extra-update.component.ts +++ b/src/main/webapp/app/entities/usuario-extra/update/usuario-extra-update.component.ts @@ -93,6 +93,7 @@ export class UsuarioExtraUpdateComponent { name, profileIcon: this.profileIcon, isAdmin: 1, + isGoogle: 0, }) .subscribe( () => (this.success = true), diff --git a/src/main/webapp/app/login/login.component.html b/src/main/webapp/app/login/login.component.html index 7bf96a4..5d32cfb 100644 --- a/src/main/webapp/app/login/login.component.html +++ b/src/main/webapp/app/login/login.component.html @@ -128,26 +128,58 @@ - - - - -
-
-

- ¿Listo para explorar? - Crea una cuenta -

+ + +
+
+ +
+ +
+ + +
- + + +
+
+

+ ¿Listo para explorar? + Crea una cuenta +

+
+ +
+
- + - + - + - + - diff --git a/src/main/webapp/app/login/login.component.scss b/src/main/webapp/app/login/login.component.scss index 192b03b..7b3227c 100644 --- a/src/main/webapp/app/login/login.component.scss +++ b/src/main/webapp/app/login/login.component.scss @@ -1,3 +1,47 @@ body { background-color: #f2f2f2 !important; } + +$white: #fff; +$google-blue: #4285f4; +$button-active-blue: #1669f2; + +.google-btn { + width: 184px; + height: 42px; + background-color: $google-blue; + 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: 11px 11px 0 0; + color: $white; + font-size: 14px; + letter-spacing: 0.2px; + font-family: 'Roboto'; + } + &:hover { + box-shadow: 0 0 6px $google-blue; + } + &:active { + background: $button-active-blue; + } +} + +@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 632548c..4d2abbd 100644 --- a/src/main/webapp/app/login/login.component.ts +++ b/src/main/webapp/app/login/login.component.ts @@ -4,6 +4,12 @@ import { Router } from '@angular/router'; import { LoginService } from 'app/login/login.service'; import { AccountService } from 'app/core/auth/account.service'; +import { SocialAuthService, SocialUser } from 'angularx-social-login'; +import { GoogleLoginProvider } from 'angularx-social-login'; +import { RegisterService } from '../account/register/register.service'; +import { TranslateService } from '@ngx-translate/core'; +import { HttpErrorResponse } from '@angular/common/http'; +import { EMAIL_ALREADY_USED_TYPE, LOGIN_ALREADY_USED_TYPE } from '../config/error.constants'; @Component({ selector: 'jhi-login', @@ -15,6 +21,9 @@ export class LoginComponent implements OnInit, AfterViewInit { username!: ElementRef; authenticationError = false; + error = false; + errorEmailExists = false; + errorUserExists = false; loginForm = this.fb.group({ username: [null, [Validators.required]], @@ -22,14 +31,33 @@ export class LoginComponent implements OnInit, AfterViewInit { rememberMe: [false], }); + user: SocialUser = new SocialUser(); + loggedIn: boolean = false; + success = false; + constructor( private accountService: AccountService, private loginService: LoginService, private router: Router, - private fb: FormBuilder + private fb: FormBuilder, + private authService: SocialAuthService, + private registerService: RegisterService, + private translateService: TranslateService ) {} ngOnInit(): void { + //Servicio para verificar si el usuario se encuentra loggeado + /*this.authService.authState.subscribe(user => { + this.user = user; + this.loggedIn = user != null; + + /!* console.log('correo: ' + user.email); + console.log('correo: ' + user.name); + console.log('ID: ' + this.user.id);*!/ + + this.authenticacionGoogle(); + }); +*/ // if already authenticated then navigate to home page this.accountService.identity().subscribe(() => { if (this.accountService.isAuthenticated()) { @@ -42,6 +70,89 @@ export class LoginComponent implements OnInit, AfterViewInit { this.username.nativeElement.focus(); } + //Inicio Google + signInWithGoogle(): void { + this.authService.signIn(GoogleLoginProvider.PROVIDER_ID).then(() => { + this.authService.authState.subscribe(user => { + this.user = user; + this.loggedIn = user != null; + + /* console.log('correo: ' + user.email); + console.log('correo: ' + user.name); + console.log('ID: ' + this.user.id);*/ + + this.authenticacionGoogle(); + }); + }); + } + + authenticacionGoogle(): void { + this.loginService.login({ username: this.user.email, password: this.user.id, rememberMe: true }).subscribe( + () => { + this.authenticationError = false; + if (!this.router.getCurrentNavigation()) { + window.localStorage.setItem('IsGoogle', 'true'); + // There were no routing during login (eg from navigationToStoredUrl) + this.router.navigate(['']); + } + }, + () => this.activateGoogle() + /*this.registerService + .save({ + login: this.user.email, + email: this.user.email, + password: this.user.id, + langKey: this.translateService.currentLang, + name: this.user.name, + profileIcon: this.randomProfilePic(), + isAdmin: 0, + }) + .subscribe( + () => (this.success = true), + response => this.processError(response) + ) */ //console.log("Usuario no existe") + ); + } + + randomProfilePic(): number { + return Math.floor(Math.random() * (28 - 1 + 1)) + 1; + } + + processError(response: HttpErrorResponse): void { + if (response.status === 400 && response.error.type === LOGIN_ALREADY_USED_TYPE) { + this.errorUserExists = true; + } else if (response.status === 400 && response.error.type === EMAIL_ALREADY_USED_TYPE) { + this.errorEmailExists = true; + } else { + this.error = true; + } + } + + refreshToken(): void { + this.authService.refreshAuthToken(GoogleLoginProvider.PROVIDER_ID); + } + + activateGoogle(): void { + this.registerService + .save({ + login: this.user.email, + email: this.user.email, + password: this.user.id, + langKey: this.translateService.currentLang, + name: this.user.name, + profileIcon: this.randomProfilePic(), + isAdmin: 0, + isGoogle: 1, + }) + .subscribe( + () => { + this.success = true; + this.authenticacionGoogle(); + }, + response => this.processError(response) + ); + } + login(): void { this.loginService .login({ diff --git a/src/main/webapp/index.html b/src/main/webapp/index.html index 1d945f6..79a5a3e 100644 --- a/src/main/webapp/index.html +++ b/src/main/webapp/index.html @@ -12,6 +12,10 @@ + + + + diff --git a/tsconfig.app.json b/tsconfig.app.json index 88fe8c0..9e5833b 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -2,7 +2,7 @@ "extends": "./tsconfig.json", "compilerOptions": { "outDir": "./target/classes/static/app", - "types": [] + "types": ["gapi", "gapi.auth2"] }, "files": ["src/main/webapp/main.ts", "src/main/webapp/polyfills.ts"], "include": ["src/main/webapp/**/*.d.ts"]