This commit is contained in:
DariusIII
2025-06-09 14:11:15 +02:00
parent 1556bd1ce5
commit ec8b22f10a
2 changed files with 5 additions and 7 deletions
@@ -161,7 +161,7 @@ class PasswordSecurityController extends Controller
// If the user has checked "trust this device", create a trust token
if ($request->has('trust_device') && $request->input('trust_device') == 1) {
// Generate a unique token for this device
$token = hash('sha256', $user->id . uniqid() . time());
$token = hash('sha256', $user->id.uniqid().time());
// Store the token with an expiry time of 30 days
$expiresAt = now()->addDays(30)->timestamp;
@@ -172,7 +172,7 @@ class PasswordSecurityController extends Controller
json_encode([
'user_id' => $user->id,
'token' => $token,
'expires_at' => $expiresAt
'expires_at' => $expiresAt,
]),
60 * 24 * 30 // 30 days in minutes
);
+3 -5
View File
@@ -23,14 +23,12 @@ class Google2FAAuthenticator extends Authenticator
/**
* Check if current device is trusted
*
* @return bool
*/
protected function isDeviceTrusted(): bool
{
$cookie = request()->cookie('2fa_trusted_device');
if (!$cookie) {
if (! $cookie) {
return false;
}
@@ -38,12 +36,12 @@ class Google2FAAuthenticator extends Authenticator
$data = json_decode($cookie, true);
// Check if cookie contains the required data
if (!isset($data['user_id'], $data['token'], $data['expires_at'])) {
if (! isset($data['user_id'], $data['token'], $data['expires_at'])) {
return false;
}
// Check if the token belongs to the current user
if ((int)$data['user_id'] !== (int)$this->getUser()->id) {
if ((int) $data['user_id'] !== (int) $this->getUser()->id) {
return false;
}