Email Confirmation Article

Eliminated unnecessary stuff in IUserService and UserService
This commit is contained in:
egmp777 2014-11-26 11:22:28 -05:00
parent 7c8eddfbcb
commit bbfa9d219a
11 changed files with 20 additions and 36 deletions

View File

@ -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() {

View File

@ -15,7 +15,7 @@ import org.springframework.stereotype.Component;
public class RegistrationListener implements ApplicationListener<OnRegistrationCompleteEvent> {
@Autowired
private IUserService service;
@Autowired
private MessageSource messages;

View File

@ -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;

View File

@ -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

View File

@ -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);
}

View File

@ -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

View File

@ -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);
}
}

View File

@ -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 {

View File

@ -29,7 +29,7 @@ public class MyUserDetailsService implements UserDetailsService {
private IUserService service;
@Autowired
private MessageSource messages;
@Autowired
public MyUserDetailsService(UserRepository repository) {
this.userRepository = repository;

View File

@ -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;

View File

@ -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