Changeset View
Changeset View
Standalone View
Standalone View
src/app/User.php
Show First 20 Lines • Show All 781 Lines • ▼ Show 20 Lines | public static function findAndAuthenticate($username, $password, $clientIP = null, $verifyMFA = true): array | ||||
} catch (\Exception $e) { | } catch (\Exception $e) { | ||||
$error = AuthAttempt::REASON_2FA_GENERIC; | $error = AuthAttempt::REASON_2FA_GENERIC; | ||||
$message = $e->getMessage(); | $message = $e->getMessage(); | ||||
} | } | ||||
} | } | ||||
// Check 2FA - Companion App | // Check 2FA - Companion App | ||||
if (!$error && $user->mfaEnabled()) { | if (!$error && $user->mfaEnabled()) { | ||||
$attempt = \App\AuthAttempt::recordAuthAttempt($user, $clientIP); | $attempt = AuthAttempt::recordAuthAttempt($user, $clientIP); | ||||
if (!$attempt->waitFor2FA()) { | if (!$attempt->waitFor2FA()) { | ||||
$error = AuthAttempt::REASON_2FA; | $error = AuthAttempt::REASON_2FA; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
if ($error) { | if ($error) { | ||||
if ($user && empty($attempt)) { | if ($user && empty($attempt)) { | ||||
$attempt = \App\AuthAttempt::recordAuthAttempt($user, $clientIP); | $attempt = AuthAttempt::recordAuthAttempt($user, $clientIP); | ||||
if (!$attempt->isAccepted()) { | if (!$attempt->isAccepted()) { | ||||
$attempt->deny($error); | $attempt->deny($error); | ||||
$attempt->save(); | $attempt->save(); | ||||
$attempt->notify(); | $attempt->notify(); | ||||
} | } | ||||
} | } | ||||
if ($user) { | if ($user) { | ||||
▲ Show 20 Lines • Show All 43 Lines • Show Last 20 Lines |