aboutsummaryrefslogtreecommitdiff
path: root/src/CamilStaps/BotleaguesApi/Database/User.php
diff options
context:
space:
mode:
authorCamil Staps2015-05-24 17:17:52 +0200
committerCamil Staps2015-05-24 17:17:52 +0200
commitab31980b116ecd497d5d4610c212ae7b1f61fada (patch)
treee1708d0790c40eb13dbcb238280a0a32be3d9c2b /src/CamilStaps/BotleaguesApi/Database/User.php
parentRoute caching (diff)
Password reminders
Diffstat (limited to 'src/CamilStaps/BotleaguesApi/Database/User.php')
-rw-r--r--src/CamilStaps/BotleaguesApi/Database/User.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/CamilStaps/BotleaguesApi/Database/User.php b/src/CamilStaps/BotleaguesApi/Database/User.php
index 0af91c3..e74bd82 100644
--- a/src/CamilStaps/BotleaguesApi/Database/User.php
+++ b/src/CamilStaps/BotleaguesApi/Database/User.php
@@ -5,6 +5,7 @@ use Illuminate\Auth\Authenticatable;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
+use Illuminate\Support\Facades\Hash;
class User extends Model implements AuthenticatableContract, CanResetPasswordContract {
@@ -22,6 +23,18 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
return UserToken::where('userId', $this->id)->where('token', $token)->where('valid_till', '>', date("Y-m-d H:i:s"))->count() > 0;
}
+ public function findPasswordReminders($token = null) {
+ $base = PasswordReminder
+ ::where('userId', $this->id)
+ ->where('used_at', null)
+ ->where('valid_till', '>', date('Y-m-d H:i:s'));
+ if ($token == null) {
+ return $base->get();
+ } else {
+ return $base->where('token', $token)->get();
+ }
+ }
+
/**
* Get the unique identifier for the user.
*
@@ -76,4 +89,8 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
public function getEmailForPasswordReset() {
return $this->email;
}
+
+ public function setPasswordAttribute($password) {
+ $this->attributes['password'] = Hash::make($password);
+ }
} \ No newline at end of file