mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:01:24 +00:00
CS fixes
This commit is contained in:
@@ -105,7 +105,7 @@ class LoginController extends Controller
|
||||
// Validate the cookie data
|
||||
if (json_last_error() === JSON_ERROR_NONE &&
|
||||
isset($cookieData['user_id'], $cookieData['token'], $cookieData['expires_at']) &&
|
||||
(int)$cookieData['user_id'] === (int)$user->id &&
|
||||
(int) $cookieData['user_id'] === (int) $user->id &&
|
||||
time() <= $cookieData['expires_at']) {
|
||||
|
||||
// Cookie is valid - mark 2FA as passed
|
||||
@@ -120,7 +120,7 @@ class LoginController extends Controller
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\Log::error('Login - Error processing trusted device cookie', [
|
||||
'error' => $e->getMessage()
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -197,7 +197,7 @@ class LoginController extends Controller
|
||||
'expires_at' => $cookieData['expires_at'],
|
||||
'current_time' => time(),
|
||||
'remaining_seconds' => $remainingSeconds,
|
||||
'remaining_minutes' => $remainingMinutes
|
||||
'remaining_minutes' => $remainingMinutes,
|
||||
]);
|
||||
|
||||
// Only preserve the cookie if it hasn't expired yet
|
||||
@@ -225,7 +225,7 @@ class LoginController extends Controller
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\Log::error('Logout - Error Processing Cookie', [
|
||||
'error' => $e->getMessage()
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ class PasswordSecurityController extends Controller
|
||||
'domain' => '',
|
||||
'secure' => request()->secure(),
|
||||
'httponly' => false,
|
||||
'samesite' => 'Lax'
|
||||
'samesite' => 'Lax',
|
||||
]
|
||||
);
|
||||
|
||||
@@ -243,6 +243,7 @@ class PasswordSecurityController extends Controller
|
||||
|
||||
// Create a response with the rendered content instead of directly outputting
|
||||
$content = app('smarty.view')->fetch($theme.'/2fa_verify.tpl');
|
||||
|
||||
return response($content);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class Google2FAMiddleware
|
||||
// Check if all required fields exist
|
||||
if (isset($cookieData['user_id'], $cookieData['token'], $cookieData['expires_at'])) {
|
||||
// Check if cookie user ID matches authenticated user
|
||||
if ((int)$cookieData['user_id'] === (int)auth()->id()) {
|
||||
if ((int) $cookieData['user_id'] === (int) auth()->id()) {
|
||||
// Check if cookie is not expired
|
||||
if (time() <= $cookieData['expires_at']) {
|
||||
// Set the session variables for 2FA authentication
|
||||
|
||||
@@ -10,10 +10,6 @@ class TrustedDevice2FAMiddleware
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): mixed
|
||||
{
|
||||
@@ -27,7 +23,7 @@ class TrustedDevice2FAMiddleware
|
||||
// If cookie data is valid and user matches
|
||||
if (json_last_error() === JSON_ERROR_NONE &&
|
||||
isset($cookieData['user_id'], $cookieData['token'], $cookieData['expires_at']) &&
|
||||
(int)$cookieData['user_id'] === (int)auth()->id() &&
|
||||
(int) $cookieData['user_id'] === (int) auth()->id() &&
|
||||
time() <= $cookieData['expires_at']) {
|
||||
|
||||
// Mark this user's session as having passed 2FA
|
||||
@@ -36,7 +32,7 @@ class TrustedDevice2FAMiddleware
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error('TrustedDevice2FAMiddleware - Error processing cookie', [
|
||||
'error' => $e->getMessage()
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -76,14 +72,14 @@ class TrustedDevice2FAMiddleware
|
||||
'domain' => '',
|
||||
'secure' => $request->secure(),
|
||||
'httponly' => false,
|
||||
'samesite' => 'Lax'
|
||||
'samesite' => 'Lax',
|
||||
]);
|
||||
|
||||
// Keep in session for backup access
|
||||
$request->session()->put('2fa_trusted_device_value', $cookieValue);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('TrustedDevice2FAMiddleware - Error setting cookie', [
|
||||
'error' => $e->getMessage()
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,17 +35,17 @@ class Google2FAAuthenticator extends Authenticator
|
||||
try {
|
||||
$data = @json_decode($cookie, true);
|
||||
|
||||
if (!is_array($data)) {
|
||||
if (! is_array($data)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Validate all required fields
|
||||
if (!isset($data['user_id'], $data['token'], $data['expires_at'])) {
|
||||
if (! isset($data['user_id'], $data['token'], $data['expires_at'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ensure the user ID matches
|
||||
if ((int)$data['user_id'] !== (int)$this->getUser()->id) {
|
||||
if ((int) $data['user_id'] !== (int) $this->getUser()->id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ class Google2FAAuthenticator extends Authenticator
|
||||
|
||||
if (json_last_error() === JSON_ERROR_NONE &&
|
||||
isset($cookieData['user_id'], $cookieData['token'], $cookieData['expires_at']) &&
|
||||
(int)$cookieData['user_id'] === (int)auth()->id() &&
|
||||
(int) $cookieData['user_id'] === (int) auth()->id() &&
|
||||
time() <= $cookieData['expires_at']) {
|
||||
|
||||
// If we have a valid cookie, force-disable 2FA
|
||||
|
||||
Reference in New Issue
Block a user