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