Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/API/V4/NGINXController.php
Show First 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | private function authorizeRequest($login, $password, $clientIP) | ||||
if (empty($password)) { | if (empty($password)) { | ||||
throw new \Exception("Empty password"); | throw new \Exception("Empty password"); | ||||
} | } | ||||
if (empty($clientIP)) { | if (empty($clientIP)) { | ||||
throw new \Exception("No client ip"); | throw new \Exception("No client ip"); | ||||
} | } | ||||
if ($userid = AuthUtils::tokenValidate($password)) { | |||||
$user = User::find($userid); | |||||
if ($user && $user->email == $login) { | |||||
return $user; | |||||
} | |||||
throw new \Exception("Password mismatch"); | |||||
} | |||||
$result = User::findAndAuthenticate($login, $password, $clientIP); | $result = User::findAndAuthenticate($login, $password, $clientIP); | ||||
if (empty($result['user'])) { | if (empty($result['user'])) { | ||||
throw new \Exception($result['errorMessage'] ?? "Unknown error"); | throw new \Exception($result['errorMessage'] ?? "Unknown error"); | ||||
} | } | ||||
// TODO: validate the user's domain is A-OK (active, confirmed, not suspended, ldapready) | // TODO: validate the user's domain is A-OK (active, confirmed, not suspended, ldapready) | ||||
// TODO: validate the user is A-OK (active, not suspended, ldapready, imapready) | // TODO: validate the user is A-OK (active, not suspended, ldapready, imapready) | ||||
▲ Show 20 Lines • Show All 288 Lines • Show Last 20 Lines |