Advertisement
Guest User

Untitled

a guest
Oct 6th, 2016
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. public function __construct($flashModel, $sessionModel) {
  2. $this->lw = new \view\LoginView();
  3. $this->sm = $sessionModel;
  4. $this->fm = $flashModel;
  5. try {
  6. if (isset($_COOKIE['Username']) && !$this->lw->isLoggingOut()) {
  7. self::$username = $_COOKIE['Username'];
  8. self::$password = $_COOKIE['Password'];
  9. $this->compareEnteredCredentials();
  10. } else {
  11. if ($this->lw->isLoggingIn() && !$this->sm->getIsLoggedIn()) {
  12. $this->setUsername();
  13. $this->setPassword();
  14. $this->compareEnteredCredentials();
  15. $this->storeUserCredentialsInCookie();
  16. } else if ($this->lw->isLoggingOut() && $this->sm->getIsLoggedIn()) {
  17. $this->removeUserCredentialsInCookie();
  18. $_SESSION['username'] = '';
  19. $_SESSION['isLoggedIn'] = false;
  20. $_SESSION['message'] = 'Bye bye!';
  21. }
  22. }
  23. } catch (\Exception $e) {
  24. $_SESSION['username'] = self::$username;
  25. $_SESSION['message'] = $e->getMessage();
  26. } finally {
  27. $this->lw->loginToLayoutView($this->fm, $this->sm);
  28. if ($this->compareEnteredCredentials() || $this->lw->isLoggingOut()) {
  29. header('Location: /');
  30. exit();
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement