Implementacion Google finalizada
This commit is contained in:
commit
1340861658
|
@ -156,7 +156,7 @@ public class UserService {
|
||||||
* Modified to register extra user data
|
* Modified to register extra user data
|
||||||
* name, iconoPerfil, fechaNacimiento, estado, pais
|
* 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
|
userRepository
|
||||||
.findOneByLogin(userDTO.getLogin().toLowerCase())
|
.findOneByLogin(userDTO.getLogin().toLowerCase())
|
||||||
.ifPresent(
|
.ifPresent(
|
||||||
|
@ -190,7 +190,13 @@ public class UserService {
|
||||||
newUser.setImageUrl(userDTO.getImageUrl());
|
newUser.setImageUrl(userDTO.getImageUrl());
|
||||||
newUser.setLangKey(userDTO.getLangKey());
|
newUser.setLangKey(userDTO.getLangKey());
|
||||||
// new user is not active
|
// new user is not active
|
||||||
newUser.setActivated(false);
|
|
||||||
|
if (isGoogle == 1) {
|
||||||
|
newUser.setActivated(true);
|
||||||
|
} else {
|
||||||
|
newUser.setActivated(false);
|
||||||
|
}
|
||||||
|
|
||||||
// new user gets registration key
|
// new user gets registration key
|
||||||
newUser.setActivationKey(RandomUtil.generateActivationKey());
|
newUser.setActivationKey(RandomUtil.generateActivationKey());
|
||||||
Set<Authority> authorities = new HashSet<>();
|
Set<Authority> authorities = new HashSet<>();
|
||||||
|
|
|
@ -67,9 +67,13 @@ public class AccountResource {
|
||||||
managedUserVM.getPassword(),
|
managedUserVM.getPassword(),
|
||||||
managedUserVM.getName(),
|
managedUserVM.getName(),
|
||||||
managedUserVM.getProfileIcon(),
|
managedUserVM.getProfileIcon(),
|
||||||
managedUserVM.getIsAdmin()
|
managedUserVM.getIsAdmin(),
|
||||||
|
managedUserVM.getIsGoogle()
|
||||||
);
|
);
|
||||||
mailService.sendActivationEmail(user);
|
|
||||||
|
if (managedUserVM.getIsGoogle() != 1) {
|
||||||
|
mailService.sendActivationEmail(user);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -24,6 +24,8 @@ public class ManagedUserVM extends AdminUserDTO {
|
||||||
|
|
||||||
private Integer isAdmin;
|
private Integer isAdmin;
|
||||||
|
|
||||||
|
private Integer isGoogle;
|
||||||
|
|
||||||
public ManagedUserVM() {
|
public ManagedUserVM() {
|
||||||
// Empty constructor needed for Jackson.
|
// Empty constructor needed for Jackson.
|
||||||
}
|
}
|
||||||
|
@ -60,6 +62,14 @@ public class ManagedUserVM extends AdminUserDTO {
|
||||||
this.isAdmin = isAdmin;
|
this.isAdmin = isAdmin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getIsGoogle() {
|
||||||
|
return isGoogle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsGoogle(Integer isGoogle) {
|
||||||
|
this.isGoogle = isGoogle;
|
||||||
|
}
|
||||||
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
|
@ -65,6 +65,7 @@ describe('Component Tests', () => {
|
||||||
name: '',
|
name: '',
|
||||||
profileIcon: 1,
|
profileIcon: 1,
|
||||||
isAdmin: 0,
|
isAdmin: 0,
|
||||||
|
isGoogle: 0,
|
||||||
});
|
});
|
||||||
expect(comp.success).toBe(true);
|
expect(comp.success).toBe(true);
|
||||||
expect(comp.errorUserExists).toBe(false);
|
expect(comp.errorUserExists).toBe(false);
|
||||||
|
|
|
@ -95,6 +95,7 @@ export class RegisterComponent implements AfterViewInit {
|
||||||
name,
|
name,
|
||||||
profileIcon: this.profileIcon,
|
profileIcon: this.profileIcon,
|
||||||
isAdmin: 0,
|
isAdmin: 0,
|
||||||
|
isGoogle: 0,
|
||||||
})
|
})
|
||||||
.subscribe(
|
.subscribe(
|
||||||
() => (this.success = true),
|
() => (this.success = true),
|
||||||
|
|
|
@ -6,6 +6,7 @@ export class Registration {
|
||||||
public langKey: string,
|
public langKey: string,
|
||||||
public name: string,
|
public name: string,
|
||||||
public profileIcon: number,
|
public profileIcon: number,
|
||||||
public isAdmin: number
|
public isAdmin: number,
|
||||||
|
public isGoogle: number
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,7 @@ describe('Component Tests', () => {
|
||||||
name: '',
|
name: '',
|
||||||
profileIcon: 1,
|
profileIcon: 1,
|
||||||
isAdmin: 1,
|
isAdmin: 1,
|
||||||
|
isGoogle: 0,
|
||||||
});
|
});
|
||||||
expect(comp.success).toBe(true);
|
expect(comp.success).toBe(true);
|
||||||
expect(comp.errorUserExists).toBe(false);
|
expect(comp.errorUserExists).toBe(false);
|
||||||
|
|
|
@ -93,6 +93,7 @@ export class UsuarioExtraUpdateComponent {
|
||||||
name,
|
name,
|
||||||
profileIcon: this.profileIcon,
|
profileIcon: this.profileIcon,
|
||||||
isAdmin: 1,
|
isAdmin: 1,
|
||||||
|
isGoogle: 0,
|
||||||
})
|
})
|
||||||
.subscribe(
|
.subscribe(
|
||||||
() => (this.success = true),
|
() => (this.success = true),
|
||||||
|
|
|
@ -47,17 +47,17 @@ export class LoginComponent implements OnInit, AfterViewInit {
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
//Servicio para verificar si el usuario se encuentra loggeado
|
//Servicio para verificar si el usuario se encuentra loggeado
|
||||||
this.authService.authState.subscribe(user => {
|
/*this.authService.authState.subscribe(user => {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.loggedIn = user != null;
|
this.loggedIn = user != null;
|
||||||
|
|
||||||
console.log('correo: ' + user.email);
|
/!* console.log('correo: ' + user.email);
|
||||||
console.log('correo: ' + user.name);
|
console.log('correo: ' + user.name);
|
||||||
console.log('ID: ' + this.user.id);
|
console.log('ID: ' + this.user.id);*!/
|
||||||
|
|
||||||
this.authenticacionGoogle();
|
this.authenticacionGoogle();
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
// if already authenticated then navigate to home page
|
// if already authenticated then navigate to home page
|
||||||
this.accountService.identity().subscribe(() => {
|
this.accountService.identity().subscribe(() => {
|
||||||
if (this.accountService.isAuthenticated()) {
|
if (this.accountService.isAuthenticated()) {
|
||||||
|
@ -72,7 +72,18 @@ export class LoginComponent implements OnInit, AfterViewInit {
|
||||||
|
|
||||||
//Inicio Google
|
//Inicio Google
|
||||||
signInWithGoogle(): void {
|
signInWithGoogle(): void {
|
||||||
this.authService.signIn(GoogleLoginProvider.PROVIDER_ID);
|
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 {
|
authenticacionGoogle(): void {
|
||||||
|
@ -83,9 +94,8 @@ export class LoginComponent implements OnInit, AfterViewInit {
|
||||||
// There were no routing during login (eg from navigationToStoredUrl)
|
// There were no routing during login (eg from navigationToStoredUrl)
|
||||||
this.router.navigate(['']);
|
this.router.navigate(['']);
|
||||||
}
|
}
|
||||||
console.log('SI existe');
|
|
||||||
},
|
},
|
||||||
() => (this.authenticationError = true)
|
() => this.activateGoogle()
|
||||||
/*this.registerService
|
/*this.registerService
|
||||||
.save({
|
.save({
|
||||||
login: this.user.email,
|
login: this.user.email,
|
||||||
|
@ -131,9 +141,13 @@ export class LoginComponent implements OnInit, AfterViewInit {
|
||||||
name: this.user.name,
|
name: this.user.name,
|
||||||
profileIcon: this.randomProfilePic(),
|
profileIcon: this.randomProfilePic(),
|
||||||
isAdmin: 0,
|
isAdmin: 0,
|
||||||
|
isGoogle: 1,
|
||||||
})
|
})
|
||||||
.subscribe(
|
.subscribe(
|
||||||
() => (this.success = true),
|
() => {
|
||||||
|
this.success = true;
|
||||||
|
this.authenticacionGoogle();
|
||||||
|
},
|
||||||
response => this.processError(response)
|
response => this.processError(response)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue