Advertisement
Guest User

Untitled

a guest
Oct 6th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. /**
  2. * @param string $username
  3. * @param string $password
  4. * @return bool
  5. * @throws Exception
  6. */
  7. public function logIn(string $username, string $password) :bool {
  8. if ($this->isLoggedIn()) {
  9. throw new Exception("");
  10. }
  11. $existingUsername = $this->config["exampleUser"]["username"];
  12. $existingPassword = $this->config["exampleUser"]["password"];
  13. if ($this->isUsernameMissing($username)) {
  14. throw new Exception("Username is missing");
  15. }
  16. if ($this->isPasswordMissing($password)) {
  17. throw new Exception("Password is missing");
  18. }
  19. if ($username === $existingUsername && $password === $existingPassword) {
  20. if (isset($_POST["LoginView::KeepMeLoggedIn"])) {
  21. $this->setUserCredentialsInCookie($username, $password);
  22. }
  23. $_SESSION["isLoggedIn"] = true;
  24. return true;
  25. } else {
  26. throw new Exception("Wrong name or password");
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement