update pom and reformat code
This commit is contained in:
parent
deeb2b20f3
commit
457baf6015
@ -17,7 +17,7 @@
|
||||
<dependency>
|
||||
<groupId>br.com.caelum</groupId>
|
||||
<artifactId>vraptor</artifactId>
|
||||
<version>4.2.0-RC3</version>
|
||||
<version>4.2.0.Final</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -50,12 +50,14 @@ public class AuthController {
|
||||
|
||||
validator.onErrorRedirectTo(this).registrationForm();
|
||||
|
||||
if(!user.getPassword().equals(request.getParameter("password_confirmation"))) {
|
||||
if(!user.getPassword()
|
||||
.equals(request.getParameter("password_confirmation"))) {
|
||||
result.include("error", "Passwords Do Not Match");
|
||||
result.redirectTo(this).registrationForm();
|
||||
}
|
||||
|
||||
user.setPassword(BCrypt.hashpw(user.getPassword(), BCrypt.gensalt()));
|
||||
user.setPassword(
|
||||
BCrypt.hashpw(user.getPassword(), BCrypt.gensalt()));
|
||||
|
||||
Object resp = userDao.add(user);
|
||||
|
||||
@ -76,13 +78,16 @@ public class AuthController {
|
||||
@Post("/login")
|
||||
public void login(HttpServletRequest request) {
|
||||
|
||||
if (request.getParameter("user.email").isEmpty() || request.getParameter("user.password").isEmpty()) {
|
||||
String password = request.getParameter("user.password");
|
||||
String email = request.getParameter("user.email");
|
||||
|
||||
if(email.isEmpty() || password.isEmpty()) {
|
||||
result.include("error", "Email/Password is Required!");
|
||||
result.redirectTo(AuthController.class).loginForm();
|
||||
}
|
||||
|
||||
User user = userDao.findByEmail(request.getParameter("user.email"));
|
||||
if (Objects.nonNull(user) && BCrypt.checkpw(request.getParameter("user.password"), user.getPassword())) {
|
||||
User user = userDao.findByEmail(email);
|
||||
if(user != null && BCrypt.checkpw(password, user.getPassword())) {
|
||||
userInfo.setUser(user);
|
||||
result.include("status", "Login Successful!");
|
||||
result.redirectTo(IndexController.class).index();
|
||||
|
@ -48,7 +48,6 @@ public class PostController {
|
||||
|
||||
@br.com.caelum.vraptor.Post("/post/add")
|
||||
public void add(Post post) {
|
||||
|
||||
post.setAuthor(userInfo.getUser());
|
||||
validator.validate(post);
|
||||
if(validator.hasErrors())
|
||||
@ -61,7 +60,8 @@ public class PostController {
|
||||
result.include("status", "Post Added Successfully");
|
||||
result.redirectTo(IndexController.class).index();
|
||||
} else {
|
||||
result.include("error", "There was an error creating the post. Try Again");
|
||||
result.include(
|
||||
"error", "There was an error creating the post. Try Again");
|
||||
result.redirectTo(this).addForm();
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ import java.util.logging.Logger;
|
||||
public class UserDao {
|
||||
|
||||
SessionFactory sessionFactory;
|
||||
Logger logger = Logger.getLogger(getClass().getName());
|
||||
|
||||
public UserDao() {
|
||||
this(null);
|
||||
|
Loading…
x
Reference in New Issue
Block a user