From 01b75699110b7ea27f681ece0d32d1ddcce7ae7a Mon Sep 17 00:00:00 2001 From: eliseekn Date: Thu, 2 Nov 2023 21:55:45 +0000 Subject: [PATCH] Fix minor bugs --- app/Database/Factories/TokenFactory.php | 2 +- app/Database/Migrations/TokensTable_20210403034738.php | 2 +- app/Http/Controllers/Auth/EmailVerificationController.php | 4 ++-- app/Http/Controllers/Auth/ForgotPasswordController.php | 4 ++-- core/Http/Validator/Validator.php | 4 ++-- core/Support/Auth.php | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/Database/Factories/TokenFactory.php b/app/Database/Factories/TokenFactory.php index cc355f6..8465078 100644 --- a/app/Database/Factories/TokenFactory.php +++ b/app/Database/Factories/TokenFactory.php @@ -26,7 +26,7 @@ public function data(): array return [ 'email' => faker()->unique()->email, 'value' => generate_token(), - 'expire' => carbon()->addHour()->toDateTimeString(), + 'expires_at' => carbon()->addHour()->toDateTimeString(), 'description' => TokenDescription::PASSWORD_RESET_TOKEN->value ]; } diff --git a/app/Database/Migrations/TokensTable_20210403034738.php b/app/Database/Migrations/TokensTable_20210403034738.php index 8db50c1..203b819 100644 --- a/app/Database/Migrations/TokensTable_20210403034738.php +++ b/app/Database/Migrations/TokensTable_20210403034738.php @@ -19,7 +19,7 @@ public function create(): void ->addPrimaryKey() ->addString('email') ->addString('value')->unique() - ->addDateTime('expire_at')->nullable() + ->addDateTime('expires_at')->nullable() ->addString('description')->default(TokenDescription::PASSWORD_RESET_TOKEN->value) ->addTimestamps() ->run(); diff --git a/app/Http/Controllers/Auth/EmailVerificationController.php b/app/Http/Controllers/Auth/EmailVerificationController.php index 7cec913..b07f917 100644 --- a/app/Http/Controllers/Auth/EmailVerificationController.php +++ b/app/Http/Controllers/Auth/EmailVerificationController.php @@ -32,7 +32,7 @@ public function notify(): void (new Token())->create([ 'email'=> $this->request->queries('email'), 'value' => $tokenValue, - 'expire' => carbon()->addDay()->toDateTimeString(), + 'expires_at' => carbon()->addDay()->toDateTimeString(), 'description' => TokenDescription::EMAIL_VERIFICATION_TOKEN->value ]); } @@ -58,7 +58,7 @@ public function verify(UpdateAction $action): void $this->response(__('invalid_password_reset_link'), 400); } - if (carbon($token->getAttribute('expire_at'))->lt(carbon())) { + if (carbon($token->getAttribute('expires_at'))->lt(carbon())) { $this->response(__('expired_password_reset_link'), 400); } diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index 6f4e065..a8473da 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -32,7 +32,7 @@ public function notify(): void (new Token())->create([ 'email'=> $this->request->inputs('email'), 'value' => $tokenValue, - 'expire' => carbon()->addHour()->toDateTimeString(), + 'expires_at' => carbon()->addHour()->toDateTimeString(), 'description' => TokenDescription::PASSWORD_RESET_TOKEN->value ]); } @@ -58,7 +58,7 @@ public function reset(): void $this->response(__('invalid_password_reset_link'), 400); } - if (carbon($token->getAttribute('expire_at'))->lt(carbon())) { + if (carbon($token->getAttribute('expires_at'))->lt(carbon())) { $this->response(__('expired_password_reset_link'), 400); } diff --git a/core/Http/Validator/Validator.php b/core/Http/Validator/Validator.php index 8942615..4e1e793 100644 --- a/core/Http/Validator/Validator.php +++ b/core/Http/Validator/Validator.php @@ -31,8 +31,8 @@ public function __construct( GUMP::add_validator( $rule->name, - $rule->errorMessage, - $rule->rule(...) + $rule->rule(...), + $rule->errorMessage ); } } diff --git a/core/Support/Auth.php b/core/Support/Auth.php index 9abf76b..4a24ec2 100644 --- a/core/Support/Auth.php +++ b/core/Support/Auth.php @@ -40,7 +40,7 @@ public static function attempt(Response $response, Request $request): bool } session()->forget(['auth_attempts', 'auth_attempts_timeout']); - session()->create('user', $user->toArray()); + session()->create('user', $user->getAttribute()); if ($request->hasInput('remember')) { cookies()->create('user', $user->getAttribute('email'), 3600 * 24 * 365);