test borked
This commit is contained in:
parent
49b528a66b
commit
2418edccfd
29 changed files with 2036 additions and 121 deletions
75
app/Auth/HashEmailUserProvider.php
Executable file
75
app/Auth/HashEmailUserProvider.php
Executable file
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
namespace App\Auth;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Contracts\Auth\UserProvider;
|
||||
|
||||
class HashEmailUserProvider implements UserProvider
|
||||
{
|
||||
/**
|
||||
* Retrieve a user by their unique identifier.
|
||||
*/
|
||||
public function retrieveById($identifier): ?Authenticatable
|
||||
{
|
||||
return User::find($identifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a user by their unique identifier and "remember me" token.
|
||||
*/
|
||||
public function retrieveByToken($identifier, $token): ?Authenticatable
|
||||
{
|
||||
$user = $this->retrieveById($identifier);
|
||||
|
||||
if (!$user) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$rememberToken = $user->getRememberToken();
|
||||
|
||||
return $rememberToken && hash_equals($rememberToken, $token) ? $user : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the "remember me" token for the given user in storage.
|
||||
*/
|
||||
public function updateRememberToken(Authenticatable $user, $token): void
|
||||
{
|
||||
$user->setRememberToken($token);
|
||||
$user->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a user by the given credentials.
|
||||
*/
|
||||
public function retrieveByCredentials(array $credentials): ?Authenticatable
|
||||
{
|
||||
if (empty($credentials['email'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return User::findByEmail($credentials['email']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a user against the given credentials.
|
||||
*
|
||||
* For passwordless authentication, this always returns true.
|
||||
*/
|
||||
public function validateCredentials(Authenticatable $user, array $credentials): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rehash the user's password if required and update the model.
|
||||
*
|
||||
* This is a no-op for passwordless authentication.
|
||||
*/
|
||||
public function rehashPasswordIfRequired(Authenticatable $user, array $credentials, bool $force = false): void
|
||||
{
|
||||
// No-op: passwordless authentication doesn't use passwords
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue