Email Confirmation Article
Eliminated unnecessary stuff in IUserService and UserService
This commit is contained in:
parent
7c8eddfbcb
commit
bbfa9d219a
|
@ -11,12 +11,12 @@ public class OnRegistrationCompleteEvent extends ApplicationEvent {
|
||||||
private final String appUrl;
|
private final String appUrl;
|
||||||
private final Locale locale;
|
private final Locale locale;
|
||||||
private final User user;
|
private final User user;
|
||||||
|
|
||||||
public OnRegistrationCompleteEvent(User user, Locale locale, String appUrl) {
|
public OnRegistrationCompleteEvent(User user, Locale locale, String appUrl) {
|
||||||
super(user);
|
super(user);
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.locale = locale;
|
this.locale = locale;
|
||||||
this.appUrl = appUrl;
|
this.appUrl = appUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAppUrl() {
|
public String getAppUrl() {
|
||||||
|
|
|
@ -15,7 +15,7 @@ import org.springframework.stereotype.Component;
|
||||||
public class RegistrationListener implements ApplicationListener<OnRegistrationCompleteEvent> {
|
public class RegistrationListener implements ApplicationListener<OnRegistrationCompleteEvent> {
|
||||||
@Autowired
|
@Autowired
|
||||||
private IUserService service;
|
private IUserService service;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MessageSource messages;
|
private MessageSource messages;
|
||||||
|
|
||||||
|
|
|
@ -17,19 +17,19 @@ public class User {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Column(name = "firstName")
|
@Column(name = "firstName")
|
||||||
private String firstName;
|
private String firstName;
|
||||||
|
|
||||||
@Column(name = "lastName")
|
@Column(name = "lastName")
|
||||||
private String lastName;
|
private String lastName;
|
||||||
|
|
||||||
@Column(name = "email")
|
@Column(name = "email")
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
@Column(name = "password")
|
@Column(name = "password")
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
@Column(name = "enabled")
|
@Column(name = "enabled")
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,6 @@ public class VerificationToken {
|
||||||
cal.setTime(new Timestamp(cal.getTime().getTime()));
|
cal.setTime(new Timestamp(cal.getTime().getTime()));
|
||||||
cal.add(Calendar.MINUTE, expiryTimeInMinutes);
|
cal.add(Calendar.MINUTE, expiryTimeInMinutes);
|
||||||
return new Date(cal.getTime().getTime());
|
return new Date(cal.getTime().getTime());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -8,8 +8,6 @@ public interface IUserService {
|
||||||
|
|
||||||
public User registerNewUserAccount(UserDto accountDto) throws EmailExistsException;
|
public User registerNewUserAccount(UserDto accountDto) throws EmailExistsException;
|
||||||
|
|
||||||
/* public User getRegisteredUser(String email);*/
|
|
||||||
|
|
||||||
public User getUser(String verificationToken);
|
public User getUser(String verificationToken);
|
||||||
|
|
||||||
public void saveRegisteredUser(User user);
|
public void saveRegisteredUser(User user);
|
||||||
|
@ -18,7 +16,5 @@ public interface IUserService {
|
||||||
|
|
||||||
public VerificationToken getVerificationToken(String VerificationToken);
|
public VerificationToken getVerificationToken(String VerificationToken);
|
||||||
|
|
||||||
public void verifyUser(VerificationToken token);
|
|
||||||
|
|
||||||
public void deleteUser(User user);
|
public void deleteUser(User user);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,15 +11,19 @@ public class UserDto {
|
||||||
@NotNull
|
@NotNull
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
private String firstName;
|
private String firstName;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
private String lastName;
|
private String lastName;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
private String matchingPassword;
|
private String matchingPassword;
|
||||||
|
|
||||||
@ValidEmail
|
@ValidEmail
|
||||||
@NotNull
|
@NotNull
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
|
|
|
@ -42,14 +42,6 @@ public class UserService implements IUserService {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @Override
|
|
||||||
public User getRegisteredUser(String email) {
|
|
||||||
|
|
||||||
User user = repository.findByEmail(email);
|
|
||||||
return user;
|
|
||||||
|
|
||||||
}*/
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public User getUser(String verificationToken) {
|
public User getUser(String verificationToken) {
|
||||||
User user = tokenRepository.findByToken(verificationToken).getUser();
|
User user = tokenRepository.findByToken(verificationToken).getUser();
|
||||||
|
@ -67,12 +59,6 @@ public class UserService implements IUserService {
|
||||||
repository.save(user);
|
repository.save(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
|
||||||
@Override
|
|
||||||
public void verifyUser(VerificationToken token) {
|
|
||||||
tokenRepository.save(token);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public void deleteUser(User user) {
|
public void deleteUser(User user) {
|
||||||
|
@ -83,8 +69,6 @@ public class UserService implements IUserService {
|
||||||
@Override
|
@Override
|
||||||
public void addVerificationToken(User user, String token) {
|
public void addVerificationToken(User user, String token) {
|
||||||
VerificationToken myToken = new VerificationToken(token, user);
|
VerificationToken myToken = new VerificationToken(token, user);
|
||||||
// user.setVerificationToken(myToken);
|
|
||||||
tokenRepository.save(myToken);
|
tokenRepository.save(myToken);
|
||||||
// repository.save(user);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class MySimpleUrlAuthenticationSuccessHandler implements AuthenticationSu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isUser) {
|
if (isUser) {
|
||||||
return "/homepage.html?user="+authentication.getName();
|
return "/homepage.html?user=" + authentication.getName();
|
||||||
} else if (isAdmin) {
|
} else if (isAdmin) {
|
||||||
return "/console.html";
|
return "/console.html";
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class MyUserDetailsService implements UserDetailsService {
|
||||||
private IUserService service;
|
private IUserService service;
|
||||||
@Autowired
|
@Autowired
|
||||||
private MessageSource messages;
|
private MessageSource messages;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public MyUserDetailsService(UserRepository repository) {
|
public MyUserDetailsService(UserRepository repository) {
|
||||||
this.userRepository = repository;
|
this.userRepository = repository;
|
||||||
|
|
|
@ -30,13 +30,13 @@ public class RegistrationController {
|
||||||
|
|
||||||
private final Logger LOGGER = LoggerFactory.getLogger(getClass());
|
private final Logger LOGGER = LoggerFactory.getLogger(getClass());
|
||||||
private IUserService service;
|
private IUserService service;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MessageSource messages;
|
private MessageSource messages;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private JavaMailSender mailSender;
|
private JavaMailSender mailSender;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ApplicationEventPublisher eventPublisher;
|
private ApplicationEventPublisher eventPublisher;
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,11 @@ init-db=false
|
||||||
hibernate.dialect=org.hibernate.dialect.MySQLDialect
|
hibernate.dialect=org.hibernate.dialect.MySQLDialect
|
||||||
hibernate.show_sql=false
|
hibernate.show_sql=false
|
||||||
hibernate.hbm2ddl.auto=create-drop
|
hibernate.hbm2ddl.auto=create-drop
|
||||||
|
|
||||||
################### JavaMail Configuration ##########################
|
################### JavaMail Configuration ##########################
|
||||||
smtp.host=smtp.gmail.com
|
smtp.host=smtp.gmail.com
|
||||||
smtp.port=465
|
smtp.port=465
|
||||||
smtp.protocol=smtps
|
smtp.protocol=smtps
|
||||||
smtp.username=xxx@gmail.com
|
smtp.username=xxx777@gmail.com
|
||||||
smtp.password=
|
smtp.password=
|
||||||
support.email=xxx@gmail.com
|
support.email=xxx777@gmail.com
|
Loading…
Reference in New Issue