21 lines
514 B
PHP
21 lines
514 B
PHP
<?php
|
|
|
|
namespace App\Repositories;
|
|
|
|
use App\Models\User;
|
|
use DateTime;
|
|
|
|
class UserRepository {
|
|
public function findByUsername(string $username) : ?User {
|
|
return User::where(['username' => $username])->first();
|
|
}
|
|
|
|
public function checkVerificationToken(User $user, string $token) : bool {
|
|
if (new DateTime() > DateTime::createFromFormat('Y-m-d H:i:s', $user->activation_token_expires_at)) {
|
|
return false;
|
|
}
|
|
|
|
return $token === $user->activation_token;
|
|
}
|
|
}
|