diff options
author | Camil Staps | 2015-05-24 22:09:13 +0200 |
---|---|---|
committer | Camil Staps | 2015-05-24 22:09:13 +0200 |
commit | 4a4b5e05576c68b382e5a6b19638da785cc81c45 (patch) | |
tree | 334a651073eea8672ddc93a96e5b9372c48c01f6 /src/CamilStaps/BotleaguesApi/Database/PasswordReminder.php | |
parent | Password reminders (diff) |
Using email as id; User & PasswordReminder
Diffstat (limited to 'src/CamilStaps/BotleaguesApi/Database/PasswordReminder.php')
-rw-r--r-- | src/CamilStaps/BotleaguesApi/Database/PasswordReminder.php | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/CamilStaps/BotleaguesApi/Database/PasswordReminder.php b/src/CamilStaps/BotleaguesApi/Database/PasswordReminder.php index 012d140..696a0a1 100644 --- a/src/CamilStaps/BotleaguesApi/Database/PasswordReminder.php +++ b/src/CamilStaps/BotleaguesApi/Database/PasswordReminder.php @@ -8,7 +8,6 @@ namespace CamilStaps\BotleaguesApi\Database; -use Illuminate\Events\Dispatcher; use Illuminate\Support\Facades\Mail; class PasswordReminder extends Model { @@ -24,7 +23,7 @@ class PasswordReminder extends Model { PasswordReminder::creating(function($passwordReminder) { $passwordReminder->valid_till = date("Y-m-d H:i:s", time() + 3600); - $user = User::findOrFail($passwordReminder->userId); + $user = User::findOrFail($passwordReminder->userEmail); Mail::send('botleagues-api::emails.auth.reminder', ['token' => $passwordReminder->token], function($message) use ($user) { $message->to($user->email, "User " . $user->id); }); @@ -36,6 +35,10 @@ class PasswordReminder extends Model { $this->save(); } + public function isValid() { + return empty($this->used_at) && strtotime($this->valid_till) > time(); + } + public function getDates() { return ['created_at']; } |