123456789101112131415161718192021222324252627282930 |
- <?php
- class LoginAction implements IAction {
- public function execute() {
- $username = $_POST['username'] ?? $_GET['username'] ?? "";
- $password = $_POST['password'] ?? $_GET['password'] ?? "";
-
- if(!isset($username) || !isset($password) || empty($username) || empty($password))
- {
- return array("error" => "Username or password is required.");
- }
- $authData = $this->domainLogin($username, $password);
- if($authData) {
- $loggerData = array();
- $loggerData['display_name'] = $authData['display_name'];
- $loggerData['user_id'] = $authData['user_id'];
- SecurityLogger::action("login", $loggerData, time());
- return $authData;
- }
- $loggerData = array();
- $loggerData['attempted_username'] = $username;
- $loggerData['ip_address'] = $_SERVER['REMOTE_ADDR'];
- SecurityLogger::action("login-failed", $loggerData, time());
- return array("error" => "Username or password is invalid.");
- }
- private function domainLogin($username, $password) {
- return (new Authorize())->login($username, $password);
- }
- }
|