Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @param string $username
- * @param string $password
- * @return bool
- * @throws Exception
- */
- public function logIn(string $username, string $password) :bool {
- if ($this->isLoggedIn()) {
- throw new Exception("");
- }
- $existingUsername = $this->config["exampleUser"]["username"];
- $existingPassword = $this->config["exampleUser"]["password"];
- if ($this->isUsernameMissing($username)) {
- throw new Exception("Username is missing");
- }
- if ($this->isPasswordMissing($password)) {
- throw new Exception("Password is missing");
- }
- if ($username === $existingUsername && $password === $existingPassword) {
- if (isset($_POST["LoginView::KeepMeLoggedIn"])) {
- $this->setUserCredentialsInCookie($username, $password);
- }
- $_SESSION["isLoggedIn"] = true;
- return true;
- } else {
- throw new Exception("Wrong name or password");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement