chrisenoch

Login.php

Mar 29th, 2019
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. <?php
  2. namespace Ijdb\Controllers;
  3. class Login {
  4. public function __construct(\Ninja\Authentication $authentication){
  5. $this->authentication = $authentication;
  6. }
  7.  
  8.  
  9. public function error()
  10. {
  11. return ['template' => 'loginerror.html.php', 'title'
  12. => 'You are not logged in'];
  13. }
  14.  
  15. public function loginForm() {
  16. return ['template' => 'login.html.php',
  17. 'title' => 'Log In'];
  18. }
  19.  
  20.  
  21. public function processLogin() {
  22. if ($this->authentication->login($_POST['email'],
  23. $_POST['password'])) {
  24. header('location: /login/success');
  25. }
  26. else {
  27. return ['template' => 'login.html.php',
  28. 'title' => 'Log In',
  29. 'variables' => [
  30. 'error' => 'Invalid username/password.'
  31. ]
  32. ];
  33. }
  34. }
  35.  
  36. public function success() {
  37. return ['template' => 'loginsuccess.html.php',
  38. 'title' => 'Login Successful'];
  39. }
  40.  
  41. public function logout() {
  42. session_destroy();
  43. return ['template' => 'logout.html.php',
  44. 'title' => 'You have been logged out'];
  45. }
  46.  
  47. }
Add Comment
Please, Sign In to add comment