Login_Page.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * Landing (login) page file.
  4. *
  5. * Provides a class with all the properties and methods to display the page.
  6. *
  7. * @author Iñigo Valentin <i@inigovalentin.com>
  8. * @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3
  9. * @package SWDB
  10. */
  11. require_once(PATH::PAGE . "Page.php");
  12. /**
  13. * Login page model.
  14. *
  15. * @category Page
  16. */
  17. class Login_Page extends Page{
  18. /**
  19. * @var bool Indicates if the user has been redirected to this page after an error.
  20. */
  21. private $is_error = false;
  22. /**
  23. * @var string Error message to show when login was unsuccesfull and
  24. * the user is back in the login page
  25. */
  26. private $error_message = "";
  27. /**
  28. * Constructor.
  29. *
  30. * Retrieves the data and initializes the variables.
  31. */
  32. public function __construct(){
  33. parent::__construct();
  34. $this->set_public(true);
  35. $this->set_view("login.php");
  36. $this->set_title("Login");
  37. $this->set_description("Login to SWDB");
  38. $this->set_canonical("login/");
  39. $this->add_css("login.css");
  40. if (http_response_code() == 401){
  41. $this->is_error = true;
  42. $this->error_message = "Invalid credentials";
  43. }
  44. $this->set_code(200);
  45. $this->set_message("OK");
  46. }
  47. /**
  48. * Checks if a error has redirected the user to shis page.
  49. *
  50. * @return bool True if there was an error, false otherwise
  51. */
  52. public function is_error(){
  53. return $this->is_error;
  54. }
  55. /**
  56. * Retrieves the error message to show.
  57. *
  58. * @return string Error message.
  59. */
  60. public function get_error_message(){
  61. return $this->error_message;
  62. }
  63. }