mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-22 07:15:49 +00:00
no change
This commit is contained in:
parent
47866a9f5d
commit
55da71a36a
13 changed files with 80 additions and 109 deletions
|
@ -8,6 +8,7 @@ package org.springframework.samples.petclinic.common;
|
|||
public final class CommonAttribute {
|
||||
|
||||
public static final String DESCRIPTION = "description";
|
||||
|
||||
public static final String ID = "id";
|
||||
|
||||
public static final String NAME = "name";
|
||||
|
|
|
@ -94,8 +94,6 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
|||
// @formatter:on
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Bean
|
||||
public ClientRegistrationRepository clientRegistrationRepository() {
|
||||
List<String> clients = Arrays.asList("google", "facebook", "github");
|
||||
|
|
|
@ -48,7 +48,8 @@ public class UserController extends WebSocketSender {
|
|||
|
||||
private final EmailService emailService;
|
||||
|
||||
public UserController(UserService userService, CredentialService credentialService, RoleService roleService, SecurityServiceImpl securityService, EmailService emailService) {
|
||||
public UserController(UserService userService, CredentialService credentialService, RoleService roleService,
|
||||
SecurityServiceImpl securityService, EmailService emailService) {
|
||||
this.userService = userService;
|
||||
this.credentialService = credentialService;
|
||||
this.roleService = roleService;
|
||||
|
@ -56,7 +57,6 @@ public class UserController extends WebSocketSender {
|
|||
this.emailService = emailService;
|
||||
}
|
||||
|
||||
|
||||
@InitBinder("user")
|
||||
public void setAllowedFields(WebDataBinder dataBinder) {
|
||||
dataBinder.setDisallowedFields(CommonAttribute.USER_ID);
|
||||
|
@ -84,7 +84,7 @@ public class UserController extends WebSocketSender {
|
|||
return CommonView.USER_REGISTRATION;
|
||||
}
|
||||
|
||||
if(userService.existByEmail(user.getEmail())) {
|
||||
if (userService.existByEmail(user.getEmail())) {
|
||||
result.rejectValue("email", "5", "Email already exist !");
|
||||
sendErrorMessage(CommonWebSocket.USER_CREATION_ERROR);
|
||||
return CommonView.USER_REGISTRATION;
|
||||
|
@ -103,15 +103,13 @@ public class UserController extends WebSocketSender {
|
|||
sendSuccessMessage(CommonWebSocket.USER_CREATED);
|
||||
|
||||
// send confirmation mail
|
||||
MessageDTO message = new MessageDTO(
|
||||
user.getFirstName(), user.getLastName(),
|
||||
"admin@petclinic.com",
|
||||
user.getEmail(),
|
||||
"New connexion",
|
||||
"Your attempt to create new account. To confirm your account, please click here : ",
|
||||
"http://localhost:8080/confirm-account?token=" + credential.getToken());
|
||||
MessageDTO message = new MessageDTO(user.getFirstName(), user.getLastName(), "admin@petclinic.com",
|
||||
user.getEmail(), "New connexion",
|
||||
"Your attempt to create new account. To confirm your account, please click here : ",
|
||||
"http://localhost:8080/confirm-account?token=" + credential.getToken());
|
||||
|
||||
// emailService.sendMailAsynch(message, Locale.getDefault());
|
||||
// TODO
|
||||
// emailService.sendMailAsynch(message, Locale.getDefault());
|
||||
|
||||
log.info(message.toString());
|
||||
|
||||
|
@ -137,7 +135,7 @@ public class UserController extends WebSocketSender {
|
|||
}
|
||||
|
||||
clientRegistrations.forEach(registration -> oauth2AuthenticationUrls.put(registration.getClientName(),
|
||||
"oauth2/authorization/" + registration.getRegistrationId()));
|
||||
"oauth2/authorization/" + registration.getRegistrationId()));
|
||||
model.put("urls", oauth2AuthenticationUrls);
|
||||
|
||||
return CommonView.USER_LOGIN;
|
||||
|
@ -161,7 +159,7 @@ public class UserController extends WebSocketSender {
|
|||
|
||||
CredentialDTO credential = credentialService.findByAuthentication(authentication);
|
||||
|
||||
if( credential.isNew()) {
|
||||
if (credential.isNew()) {
|
||||
|
||||
// first time authentification with this provider
|
||||
credential = credentialService.saveNew(authentication);
|
||||
|
@ -169,7 +167,7 @@ public class UserController extends WebSocketSender {
|
|||
|
||||
UserDTO user = userService.findByEmail(email);
|
||||
|
||||
if(user == null) {
|
||||
if (user == null) {
|
||||
user = new UserDTO();
|
||||
user.setEmail(email);
|
||||
user.encode(credential.getPassword());
|
||||
|
@ -181,13 +179,11 @@ public class UserController extends WebSocketSender {
|
|||
}
|
||||
|
||||
// send confirmation mail
|
||||
MessageDTO message = new MessageDTO(
|
||||
firstName, lastName,
|
||||
"admin@petclinic.com",
|
||||
credential.getEmail(),
|
||||
"New connexion from " + credential.getProvider(),
|
||||
"Your attempt to connect from " + credential.getProvider() + " To confirm this connection, please click the link below : ",
|
||||
"http://localhost:8080/confirm-account?token=" + credential.getToken());
|
||||
MessageDTO message = new MessageDTO(firstName, lastName, "admin@petclinic.com", credential.getEmail(),
|
||||
"New connexion from " + credential.getProvider(),
|
||||
"Your attempt to connect from " + credential.getProvider()
|
||||
+ " To confirm this connection, please click the link below : ",
|
||||
"http://localhost:8080/confirm-account?token=" + credential.getToken());
|
||||
|
||||
log.info(message.toString());
|
||||
emailService.sendMailAsynch(message, Locale.getDefault());
|
||||
|
@ -196,13 +192,13 @@ public class UserController extends WebSocketSender {
|
|||
authentication.eraseCredentials();
|
||||
SecurityContextHolder.clearContext();
|
||||
|
||||
} else if( credential.isVerified()) {
|
||||
securityService.autoLogin(credential.getEmail(),credential.getPassword());
|
||||
}
|
||||
else if (credential.isVerified()) {
|
||||
securityService.autoLogin(credential.getEmail(), credential.getPassword());
|
||||
String message = String.format(CommonWebSocket.USER_LOGGED_IN, firstName, lastName);
|
||||
sendSuccessMessage(message);
|
||||
}
|
||||
|
||||
|
||||
return CommonView.HOME;
|
||||
}
|
||||
|
||||
|
@ -219,7 +215,7 @@ public class UserController extends WebSocketSender {
|
|||
// find corresponding user
|
||||
UserDTO user = userService.findByEmail(credential.getEmail());
|
||||
|
||||
securityService.autoLogin(credential.getEmail(),credential.getPassword());
|
||||
securityService.autoLogin(credential.getEmail(), credential.getPassword());
|
||||
model.addAttribute(CommonAttribute.USER, user);
|
||||
return CommonView.USER_UPDATE;
|
||||
}
|
||||
|
@ -251,7 +247,8 @@ public class UserController extends WebSocketSender {
|
|||
model.addAttribute(CommonAttribute.USER, user);
|
||||
model.addAttribute(CommonAttribute.USER_ID, user.getId());
|
||||
return CommonView.USER_UPDATE;
|
||||
} catch (Exception exception) {
|
||||
}
|
||||
catch (Exception exception) {
|
||||
// user don't have profile
|
||||
}
|
||||
|
||||
|
@ -266,7 +263,7 @@ public class UserController extends WebSocketSender {
|
|||
return CommonView.USER_UPDATE;
|
||||
}
|
||||
|
||||
if(!user.getPassword().equals(user.getMatchingPassword())) {
|
||||
if (!user.getPassword().equals(user.getMatchingPassword())) {
|
||||
sendErrorMessage(CommonWebSocket.USER_UPDATED_ERROR);
|
||||
return CommonView.USER_UPDATE;
|
||||
}
|
||||
|
@ -290,7 +287,7 @@ public class UserController extends WebSocketSender {
|
|||
}
|
||||
|
||||
@GetMapping("/user/{userId}/edit/password")
|
||||
public String editPassword(@PathVariable("userId") Integer userId, Model model){
|
||||
public String editPassword(@PathVariable("userId") Integer userId, Model model) {
|
||||
try {
|
||||
UserDTO operator = (UserDTO) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
UserDTO user = userService.findById(userId);
|
||||
|
@ -300,7 +297,8 @@ public class UserController extends WebSocketSender {
|
|||
model.addAttribute(CommonAttribute.USER_ID, user.getId());
|
||||
return CommonView.USER_CHANGE_PASSWORD;
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
}
|
||||
catch (Exception exception) {
|
||||
// user don't have profile
|
||||
}
|
||||
|
||||
|
@ -309,20 +307,19 @@ public class UserController extends WebSocketSender {
|
|||
|
||||
@PostMapping("/user/{userId}/edit/password")
|
||||
public String updatePassword(@ModelAttribute(CommonAttribute.USER) @Valid UserDTO user, BindingResult bindingResult,
|
||||
@PathVariable(CommonAttribute.USER_ID) Integer userId,
|
||||
@Param("oldPassword") String oldPassword,
|
||||
@Param("newPassword") String newPassword,
|
||||
@Param("newMatchingPassword") String newMatchingPassword, Model model) {
|
||||
@PathVariable(CommonAttribute.USER_ID) Integer userId, @Param("oldPassword") String oldPassword,
|
||||
@Param("newPassword") String newPassword, @Param("newMatchingPassword") String newMatchingPassword,
|
||||
Model model) {
|
||||
|
||||
// verify the matching with old password
|
||||
if(!user.matches(oldPassword)){
|
||||
if (!user.matches(oldPassword)) {
|
||||
bindingResult.rejectValue("password", "6", "Bad password !");
|
||||
model.addAttribute(CommonAttribute.USER, user);
|
||||
return CommonView.USER_CHANGE_PASSWORD;
|
||||
}
|
||||
|
||||
// verify matching between two password
|
||||
if(!newPassword.equals(newMatchingPassword)){
|
||||
if (!newPassword.equals(newMatchingPassword)) {
|
||||
bindingResult.rejectValue("password", "7", "Bad matching password !");
|
||||
model.addAttribute(CommonAttribute.USER, user);
|
||||
return CommonView.USER_CHANGE_PASSWORD;
|
||||
|
@ -339,12 +336,12 @@ public class UserController extends WebSocketSender {
|
|||
model.addAttribute(CommonAttribute.USER, user);
|
||||
return CommonView.USER_UPDATE_R;
|
||||
}
|
||||
} catch (NullPointerException exception) {
|
||||
}
|
||||
catch (NullPointerException exception) {
|
||||
log.error(exception.getMessage());
|
||||
}
|
||||
|
||||
return CommonView.HOME;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -40,6 +40,9 @@ public class CredentialDTO extends BaseDTO {
|
|||
+ CommonParameter.PASSWORD_MIN + " AND " + CommonParameter.PASSWORD_MAX + " !")
|
||||
private String password;
|
||||
|
||||
public CredentialDTO() {
|
||||
}
|
||||
|
||||
public CredentialDTO(UserDTO user) {
|
||||
this.verified = false;
|
||||
this.setToken();
|
||||
|
@ -61,7 +64,6 @@ public class CredentialDTO extends BaseDTO {
|
|||
this.provider = CommonParameter.DEFAULT_PROVIDER;
|
||||
}
|
||||
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
@ -119,4 +121,5 @@ public class CredentialDTO extends BaseDTO {
|
|||
|
||||
return this.expiration.after(Date.from(Instant.now()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -113,14 +113,9 @@ public class MessageDTO implements Serializable {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MessageDTO{" +
|
||||
"first name='" + firstName + '\'' +
|
||||
", last name='" + lastName + '\'' +
|
||||
", from='" + from + '\'' +
|
||||
", to='" + to + '\'' +
|
||||
", subject='" + subject + '\'' +
|
||||
", content='" + content + '\'' +
|
||||
", link='" + link + '\'' +
|
||||
'}';
|
||||
return "MessageDTO{" + "first name='" + firstName + '\'' + ", last name='" + lastName + '\'' + ", from='" + from
|
||||
+ '\'' + ", to='" + to + '\'' + ", subject='" + subject + '\'' + ", content='" + content + '\''
|
||||
+ ", link='" + link + '\'' + '}';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,4 +10,5 @@ import java.io.Serializable;
|
|||
* @author Paul-Emmanuel DOS SANTOS FACAO
|
||||
*/
|
||||
public class RoleDTO extends NamedDTO implements Serializable {
|
||||
|
||||
}
|
||||
|
|
|
@ -25,22 +25,25 @@ public class UserDTO extends PersonDTO implements Serializable, UserDetails {
|
|||
private String email;
|
||||
|
||||
@Size(min = CommonParameter.PASSWORD_MIN, max = CommonParameter.PASSWORD_MAX, message = CommonError.FORMAT_BETWEEN
|
||||
+ CommonParameter.PASSWORD_MIN + " AND " + CommonParameter.PASSWORD_MAX + " !")
|
||||
+ CommonParameter.PASSWORD_MIN + " AND " + CommonParameter.PASSWORD_MAX + " !")
|
||||
private String password;
|
||||
|
||||
@Size(min = CommonParameter.PASSWORD_MIN, max = CommonParameter.PASSWORD_MAX, message = CommonError.FORMAT_BETWEEN
|
||||
+ CommonParameter.PASSWORD_MIN + " AND " + CommonParameter.PASSWORD_MAX + " !")
|
||||
+ CommonParameter.PASSWORD_MIN + " AND " + CommonParameter.PASSWORD_MAX + " !")
|
||||
private String matchingPassword;
|
||||
|
||||
private boolean enabled;
|
||||
|
||||
private boolean accountNonExpired;
|
||||
|
||||
private boolean accountNonLocked;
|
||||
|
||||
private boolean credentialsNonExpired;
|
||||
|
||||
private Set<RoleDTO> roles;
|
||||
|
||||
|
||||
@Size(max = CommonParameter.PHONE_MAX, message = CommonError.FORMAT_LESS + CommonParameter.PHONE_MAX)
|
||||
// @Pattern(regexp = CommonParameter.PHONE_REGEXP, message = CommonError.PHONE_FORMAT)
|
||||
// @Pattern(regexp = CommonParameter.PHONE_REGEXP, message = CommonError.PHONE_FORMAT)
|
||||
private String telephone;
|
||||
|
||||
@Size(max = CommonParameter.STREET_MAX, message = CommonError.FORMAT_LESS + CommonParameter.STREET_MAX + " !")
|
||||
|
@ -140,7 +143,7 @@ public class UserDTO extends PersonDTO implements Serializable, UserDetails {
|
|||
public Collection<? extends GrantedAuthority> getAuthorities() {
|
||||
Set<GrantedAuthority> grantedAuthorities = new HashSet<>();
|
||||
|
||||
this.roles.forEach(role -> grantedAuthorities.add(new SimpleGrantedAuthority(role.getName())));
|
||||
this.roles.forEach(role -> grantedAuthorities.add(new SimpleGrantedAuthority(role.getName())));
|
||||
|
||||
return grantedAuthorities;
|
||||
}
|
||||
|
@ -183,7 +186,6 @@ public class UserDTO extends PersonDTO implements Serializable, UserDetails {
|
|||
this.telephone = telephone;
|
||||
}
|
||||
|
||||
|
||||
public String getStreet1() {
|
||||
return street1;
|
||||
}
|
||||
|
@ -234,23 +236,12 @@ public class UserDTO extends PersonDTO implements Serializable, UserDetails {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserDTO{" +
|
||||
"email='" + email + '\'' +
|
||||
", password='" + password + '\'' +
|
||||
", matchingPassword='" + matchingPassword + '\'' +
|
||||
", user enabled=" + enabled +
|
||||
", account not expired=" + accountNonExpired +
|
||||
", account not locked=" + accountNonLocked +
|
||||
", credentials not xxpired=" + credentialsNonExpired +
|
||||
", roles=" + roles +
|
||||
", telephone='" + telephone + '\'' +
|
||||
", street1='" + street1 + '\'' +
|
||||
", street2='" + street2 + '\'' +
|
||||
", street3='" + street3 + '\'' +
|
||||
", zipCode='" + zipCode + '\'' +
|
||||
", city='" + city + '\'' +
|
||||
", country='" + country + '\'' +
|
||||
'}';
|
||||
return "UserDTO{" + "email='" + email + '\'' + ", password='" + password + '\'' + ", matchingPassword='"
|
||||
+ matchingPassword + '\'' + ", user enabled=" + enabled + ", account not expired=" + accountNonExpired
|
||||
+ ", account not locked=" + accountNonLocked + ", credentials not xxpired=" + credentialsNonExpired
|
||||
+ ", roles=" + roles + ", telephone='" + telephone + '\'' + ", street1='" + street1 + '\''
|
||||
+ ", street2='" + street2 + '\'' + ", street3='" + street3 + '\'' + ", zipCode='" + zipCode + '\''
|
||||
+ ", city='" + city + '\'' + ", country='" + country + '\'' + '}';
|
||||
}
|
||||
|
||||
public void encode(String rawPassword) {
|
||||
|
@ -265,4 +256,5 @@ public class UserDTO extends PersonDTO implements Serializable, UserDetails {
|
|||
|
||||
return bCryptPasswordEncoder.matches(rawPassword, this.password);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.UUID;
|
|||
@Entity(name = "Credential")
|
||||
@Table(name = "credentials")
|
||||
public class Credential extends BaseEntity {
|
||||
|
||||
private static final int TOKEN_EXPIRATION = 60 * 24;
|
||||
|
||||
@NotNull
|
||||
|
@ -35,7 +36,7 @@ public class Credential extends BaseEntity {
|
|||
|
||||
@NotNull
|
||||
@Size(min = CommonParameter.PASSWORD_MIN, max = CommonParameter.PASSWORD_MAX, message = CommonError.FORMAT_BETWEEN
|
||||
+ CommonParameter.PASSWORD_MIN + " AND " + CommonParameter.PASSWORD_MAX + " !")
|
||||
+ CommonParameter.PASSWORD_MIN + " AND " + CommonParameter.PASSWORD_MAX + " !")
|
||||
@Column(name = "password", length = CommonParameter.PASSWORD_MAX)
|
||||
private String password;
|
||||
|
||||
|
@ -49,7 +50,6 @@ public class Credential extends BaseEntity {
|
|||
@Column(name = "expiration")
|
||||
private Date expiration;
|
||||
|
||||
|
||||
public Integer getProviderId() {
|
||||
return providerId;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public class User extends Person implements Serializable, UserDetails {
|
|||
private String email;
|
||||
|
||||
@Size(min = CommonParameter.PASSWORD_MIN, max = CommonParameter.PASSWORD_MAX, message = CommonError.FORMAT_BETWEEN
|
||||
+ CommonParameter.PASSWORD_MIN + " AND " + CommonParameter.PASSWORD_MAX + " !")
|
||||
+ CommonParameter.PASSWORD_MIN + " AND " + CommonParameter.PASSWORD_MAX + " !")
|
||||
@Column(name = "password", length = CommonParameter.PASSWORD_MAX)
|
||||
private String password;
|
||||
|
||||
|
@ -55,15 +55,14 @@ public class User extends Person implements Serializable, UserDetails {
|
|||
|
||||
@ManyToMany(fetch = FetchType.EAGER)
|
||||
@JoinTable(name = "users_roles", joinColumns = @JoinColumn(name = "user_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "role_id"))
|
||||
inverseJoinColumns = @JoinColumn(name = "role_id"))
|
||||
private Set<Role> roles;
|
||||
|
||||
@Size(max = CommonParameter.PHONE_MAX, message = CommonError.FORMAT_LESS + CommonParameter.PHONE_MAX)
|
||||
// @Pattern(regexp = CommonParameter.PHONE_REGEXP, message = CommonError.PHONE_FORMAT)
|
||||
// @Pattern(regexp = CommonParameter.PHONE_REGEXP, message = CommonError.PHONE_FORMAT)
|
||||
@Column(name = "telephone", length = CommonParameter.EMAIL_MAX)
|
||||
private String telephone;
|
||||
|
||||
|
||||
@Size(max = CommonParameter.STREET_MAX, message = CommonError.FORMAT_LESS + CommonParameter.STREET_MAX + " !")
|
||||
@Column(name = "street1", length = CommonParameter.STREET_MAX)
|
||||
private String street1;
|
||||
|
@ -146,12 +145,11 @@ public class User extends Person implements Serializable, UserDetails {
|
|||
this.credentialsNonExpired = credentialsNonExpired;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Collection<? extends GrantedAuthority> getAuthorities() {
|
||||
Set<GrantedAuthority> grantedAuthorities = new HashSet<>();
|
||||
|
||||
this.roles.forEach(role -> grantedAuthorities.add(new SimpleGrantedAuthority(role.getName())));
|
||||
this.roles.forEach(role -> grantedAuthorities.add(new SimpleGrantedAuthority(role.getName())));
|
||||
|
||||
return grantedAuthorities;
|
||||
}
|
||||
|
@ -182,7 +180,6 @@ public class User extends Person implements Serializable, UserDetails {
|
|||
getRolesInternal().add(role);
|
||||
}
|
||||
|
||||
|
||||
public void setRoles(Set<Role> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
@ -195,7 +192,6 @@ public class User extends Person implements Serializable, UserDetails {
|
|||
this.telephone = telephone;
|
||||
}
|
||||
|
||||
|
||||
public String getStreet1() {
|
||||
return street1;
|
||||
}
|
||||
|
@ -244,5 +240,4 @@ public class User extends Person implements Serializable, UserDetails {
|
|||
this.country = country;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -28,7 +28,8 @@ public class CredentialService {
|
|||
|
||||
private final ModelMapper modelMapper = new ModelMapper();
|
||||
|
||||
public CredentialService(CredentialRepository credentialRepository, BCryptPasswordEncoder bCryptPasswordEncoder, AuthProviderRepository authProviderRepository) {
|
||||
public CredentialService(CredentialRepository credentialRepository, BCryptPasswordEncoder bCryptPasswordEncoder,
|
||||
AuthProviderRepository authProviderRepository) {
|
||||
this.credentialRepository = credentialRepository;
|
||||
this.bCryptPasswordEncoder = bCryptPasswordEncoder;
|
||||
this.authProviderRepository = authProviderRepository;
|
||||
|
@ -86,7 +87,6 @@ public class CredentialService {
|
|||
return entityToDTO(credential);
|
||||
}
|
||||
|
||||
|
||||
public CredentialDTO save(CredentialDTO dto) {
|
||||
Credential credential = dtoToEntity(dto);
|
||||
credential = credentialRepository.save(credential);
|
||||
|
@ -112,7 +112,8 @@ public class CredentialService {
|
|||
public CredentialDTO saveNew(OAuth2AuthenticationToken authentication) {
|
||||
Credential credential = new Credential();
|
||||
|
||||
AuthProvider authProvider = authProviderRepository.findByName(authentication.getAuthorizedClientRegistrationId());
|
||||
AuthProvider authProvider = authProviderRepository
|
||||
.findByName(authentication.getAuthorizedClientRegistrationId());
|
||||
|
||||
credential.setEmail(authentication.getPrincipal().getAttribute("email"));
|
||||
credential.setProviderId(authProvider.getId());
|
||||
|
@ -125,5 +126,4 @@ public class CredentialService {
|
|||
return entityToDTO(credential);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -40,16 +40,13 @@ public class EmailService {
|
|||
@Autowired
|
||||
protected ITemplateEngine templateEngine;
|
||||
|
||||
|
||||
/**
|
||||
* sendMailAsynch : for the controller MailController
|
||||
* send mail asynchronously
|
||||
*
|
||||
* sendMailAsynch : for the controller MailController send mail asynchronously
|
||||
* @param messageDTO : message to be send by mail
|
||||
* @param locale : not used now
|
||||
*/
|
||||
@Async
|
||||
public void sendMailAsynch(MessageDTO messageDTO, Locale locale){
|
||||
public void sendMailAsynch(MessageDTO messageDTO, Locale locale) {
|
||||
sendMail(messageDTO, locale);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,13 +39,9 @@ public class UserService implements BaseService<User, UserDTO> {
|
|||
user.setPassword(dto.getPassword());
|
||||
|
||||
/*
|
||||
if (dto.getRoles() != null) {
|
||||
for (RoleDTO roleDTO : dto.getRoles()) {
|
||||
Role role = modelMapper.map(roleDTO, Role.class);
|
||||
user.addRole(role);
|
||||
}
|
||||
}
|
||||
*/
|
||||
* if (dto.getRoles() != null) { for (RoleDTO roleDTO : dto.getRoles()) { Role
|
||||
* role = modelMapper.map(roleDTO, Role.class); user.addRole(role); } }
|
||||
*/
|
||||
return user;
|
||||
}
|
||||
|
||||
|
@ -58,14 +54,10 @@ public class UserService implements BaseService<User, UserDTO> {
|
|||
UserDTO userDto = modelMapper.map(entity, UserDTO.class);
|
||||
userDto.setPassword(entity.getPassword());
|
||||
userDto.setMatchingPassword(entity.getPassword());
|
||||
/*
|
||||
if (entity.getRoles() != null) {
|
||||
for (Role role : entity.getRoles()) {
|
||||
RoleDTO roleDTO = modelMapper.map(role, RoleDTO.class);
|
||||
userDto.addRole(roleDTO);
|
||||
}
|
||||
}
|
||||
*/
|
||||
/*
|
||||
* if (entity.getRoles() != null) { for (Role role : entity.getRoles()) { RoleDTO
|
||||
* roleDTO = modelMapper.map(role, RoleDTO.class); userDto.addRole(roleDTO); } }
|
||||
*/
|
||||
return userDto;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,8 +44,8 @@ spring.h2.console.path=/h2-console
|
|||
spring.security.oauth2.client.registration.google.client-id=${OAUTH2_GOOGLE_CLIENT_ID}
|
||||
spring.security.oauth2.client.registration.google.client-secret=${OAUTH2_GOOGLE_CLIENT_SECRET}
|
||||
|
||||
spring.security.oauth2.client.registration.github.client-id=${OAUTH2_GITHUB_CLIENT_ID}
|
||||
spring.security.oauth2.client.registration.github.client-secret=${OAUTH2_GITHUB_CLIENT_SECRET}
|
||||
#spring.security.oauth2.client.registration.github.client-id=${OAUTH2_GITHUB_CLIENT_ID}
|
||||
#spring.security.oauth2.client.registration.github.client-secret=${OAUTH2_GITHUB_CLIENT_SECRET}
|
||||
|
||||
|
||||
#spring.security.oauth2.client.registration.facebook.client-id=<your client id>
|
||||
|
|
Loading…
Reference in a new issue