Advertisement
Guest User

Untitled

a guest
Aug 29th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. #{form @Application.auth(), id:'loginForm'}
  2. <p>
  3. <label>LOGIN:</label>
  4. <input type="text" id="login" name="login" value="${flash.login}" />
  5. </p>
  6. <p>
  7. <label>PASSWORD:</label>
  8. <input type="password" id="pass" name="pass" value="" />
  9. </p>
  10. <p class="action">
  11. <input type="submit" value="Go!" onclick="valid()">
  12. </p>
  13. #{/form}
  14. <p>
  15. <a href="@{registration()}">Зарегестрироваться</a>
  16.  
  17. public static void auth(String username, String password) {
  18. User user = User.findByUsername(username);
  19. if (username == null || !user.checkPass(password)) {
  20. flash.error("Bad username or password");
  21. }
  22. session.put("username", username);
  23. if (user != null) {
  24. flash.success("Welcome %s !", username);
  25. profileUser();
  26. }
  27. }
  28.  
  29. File routes:
  30. # Home page
  31. GET / controllers.Application.index()
  32. POST /login controllers.Application.auth()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement