LoginAction.class.php 651 B

12345678910111213141516171819202122
  1. <?php
  2. class LoginAction implements IAction {
  3. public function execute() {
  4. $username = isset($_POST['username']) ? $_POST['username'] : "";
  5. $password = isset($_POST['password']) ? $_POST['password'] : "";
  6. if(!isset($username) || !isset($password) || empty($username) || empty($password))
  7. {
  8. return array("error" => "Username or password is required.");
  9. }
  10. $authData = $this->domainLogin($username, $password);
  11. if($authData) {
  12. return $authData;
  13. }
  14. return array("error" => "Username or password is invalid.");
  15. }
  16. private function domainLogin($username, $password) {
  17. return (new Authorize())->login($username, $password);
  18. }
  19. }