Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. <?php
  2.  
  3. class LoginController {
  4. private $loginView;
  5. private $userStorage;
  6. public function __construct ($v, $us) {
  7. $this->loginView = $v;
  8. $this->userStorage = $us;
  9. }
  10. public function doLogin() {
  11. if($this->loginView->userWantsToLogin()) {
  12. if($this->userStorage->authAUser($this->loginView->getUserCredentials())) {
  13. $_SESSION["loggedIn"] = true;
  14. if(isset($_SESSION["showWelcome"])) {
  15. if($_SESSION["showWelcome"] == false){
  16. $this->showWelcome();
  17. }
  18. } else {
  19. $this->showWelcome();
  20. }
  21. return true;
  22. } else {
  23. $this->loginView->setMessage('Wrong name or password');
  24. return false;
  25. }
  26. }
  27. }
  28. public function doLogout(){
  29. if($this->loginView->userWantsToLogout() && $_SESSION["loggedIn"] = true) {
  30. unset($_SESSION["loggedIn"]);
  31. if(isset($_SESSION["showBye"])) {
  32. if($_SESSION["showBye"] == false){
  33. $this->showBye();
  34. }
  35. }
  36. $_SESSION["showWelcome"] = false;
  37. }
  38. }
  39. private function showWelcome() {
  40. $this->loginView->setMessage('Welcome');
  41. $_SESSION["showWelcome"] = true;
  42. }
  43. private function showBye () {
  44. $this->loginView->setMessage('Bye bye!');
  45. $_SESSION["showBye"] = true;
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement