Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. [CompletionException: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException]
  2.  
  3. package controllers;
  4.  
  5. public class LoginController extends Controller{
  6.  
  7. private FormFactory formFactory;
  8.  
  9. private Environment env;
  10.  
  11. @Inject
  12. public LoginController(Environment e, FormFactory f){
  13. this.env = e;
  14. this.formFactory = f;
  15. }
  16.  
  17. public Result login(){
  18.  
  19. Form<Login> loginForm = formFactory.form(Login.class);
  20.  
  21. return ok(login.render(loginForm));
  22.  
  23. }
  24.  
  25. public Result loginSubmit(){
  26.  
  27. Form<Login> loginForm = formFactory.form(Login.class).bindFromRequest();
  28.  
  29. if(loginForm.hasErrors()){
  30.  
  31. return badRequest(login.render(loginForm));
  32.  
  33. }
  34. else{
  35.  
  36. session().clear();
  37.  
  38. session("email", loginForm.get().getEmail());
  39.  
  40. }
  41.  
  42. return redirect(controllers.routes.HomeController.index());
  43. }
  44. }
  45.  
  46. package models;
  47.  
  48. @Entity
  49. public class User extends Model {
  50.  
  51. @Id
  52. private String email;
  53.  
  54. @Constraints.Required
  55. private String role;
  56. @Constraints.Required
  57. private String name;
  58. @Constraints.Required
  59. private String password;
  60.  
  61. public User(String role, String email, String password) {
  62.  
  63. this.role = role;
  64. this.email = email;
  65. this.password = password;
  66. }
  67.  
  68. public User() {
  69. }
  70.  
  71. GETTERS AND SETTERS FOR EACH VARIABLE HERE
  72.  
  73. public static Finder<String,User> find = new Finder<String,User>(User.class);
  74.  
  75. public static List<User> findAll(){
  76. return User.find.all();
  77. }
  78.  
  79. public static User authenticate(String email, String password){
  80. User user = null;
  81.  
  82. if(find.where().eq("email",email).eq("password",password).findUnique() != null){
  83.  
  84. user = find.ref(email);
  85.  
  86. }
  87.  
  88. return user;
  89. }
  90. }
  91.  
  92. public class Login {
  93.  
  94. private String email;
  95. private String password;
  96.  
  97. public static List<User> findAll(){
  98. return User.find.all();
  99. }
  100.  
  101. public static User authenticate(String email, String password){
  102. return find.where().eq("email",email).eq("password",password).findUnique();
  103. }
  104.  
  105. GETTERS AND SETTERS HERE
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement