Skip to content

Commit

Permalink
feat: add todo
Browse files Browse the repository at this point in the history
  • Loading branch information
kaioken committed Jul 9, 2024
1 parent 300b465 commit 8ff0122
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/Kanvas/Auth/Services/ForgotPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Kanvas\Apps\Models\Apps;
use Kanvas\Enums\AppEnums;
use Kanvas\Exceptions\ModelNotFoundException as ExceptionsModelNotFoundException;
use Kanvas\Notifications\Templates\ResetPassword;
use Kanvas\Users\Models\Users;
use Kanvas\Users\Models\UsersAssociatedApps;
Expand Down Expand Up @@ -48,12 +49,16 @@ public function forgot(string $email): Users
*/
public function reset(string $newPassword, string $hashKey): bool
{
$recoverUser = UsersAssociatedApps::fromApp($this->app)
->notDeleted()
->where([
'companies_id' => AppEnums::GLOBAL_COMPANY_ID->getValue(),
'user_activation_forgot' => $hashKey,
])->firstOrFail();
try {
$recoverUser = UsersAssociatedApps::fromApp($this->app)
->notDeleted()
->where([
'companies_id' => AppEnums::GLOBAL_COMPANY_ID->getValue(),
'user_activation_forgot' => $hashKey,
])->firstOrFail();
} catch (ModelNotFoundException $e) {
throw new ExceptionsModelNotFoundException('Password reset link has expired, request a new link.');
}

return $recoverUser->user()->firstOrFail()->resetPassword($newPassword, $this->app);
}
Expand Down

0 comments on commit 8ff0122

Please sign in to comment.