diff --git a/Account/AccountManager.php b/Account/AccountManager.php index cd0c7d81d..af1eae98b 100644 --- a/Account/AccountManager.php +++ b/Account/AccountManager.php @@ -108,29 +108,6 @@ class AccountManager implements \Countable return $this->accounts[$id] ?? new NullAccount(); } - /** - * Login user. - * - * @param int $account Account id - * @param string $login Username - * @param string $password Password - * - * @return int - * - * @throws \Exception Throws this exception if the account to login is not found in the AccountManager. - * - * @since 1.0.0 - * @author Dennis Eichhorn - */ - public function login(int $account, string $login, string $password) : int - { - if (!isset($this->accounts[$account])) { - throw new \Exception('Account not found in the account manager.'); - } - - return $this->auth->login($login, $password); - } - /** * Add account. * diff --git a/Auth/Auth.php b/Auth/Auth.php index 103c8358c..4ac978b57 100644 --- a/Auth/Auth.php +++ b/Auth/Auth.php @@ -86,67 +86,6 @@ class Auth return $uid; } - /** - * Login user. - * - * @param string $login Username - * @param string $password Password - * - * @return int Login code - * - * @todo move this to the admin accountMapper - * - * @since 1.0.0 - * @author Dennis Eichhorn - */ - public function login(string $login, string $password) : int - { - try { - $result = null; - - switch ($this->connection->getType()) { - case DatabaseType::MYSQL: - - $sth = $this->connection->con->prepare( - 'SELECT - `' . $this->connection->prefix . 'account`.* - FROM - `' . $this->connection->prefix . 'account` - WHERE - `account_login` = :login' - ); - $sth->bindValue(':login', $login, \PDO::PARAM_STR); - $sth->execute(); - - $result = $sth->fetchAll(); - break; - } - - // TODO: check if user is allowed to login on THIS page (backend|frontend|etc...) - - if (!isset($result[0])) { - return LoginReturnType::WRONG_USERNAME; - } - - $result = $result[0]; - - if ($result['account_tries'] <= 0) { - return LoginReturnType::WRONG_INPUT_EXCEEDED; - } - - if (password_verify($password, $result['account_password'])) { - $this->session->set('UID', $result['account_id']); - $this->session->save(); - - return LoginReturnType::OK; - } - - return LoginReturnType::WRONG_PASSWORD; - } catch (\Exception $e) { - return LoginReturnType::FAILURE; - } - } - /** * Logout the given user. *