aboutsummaryrefslogtreecommitdiff
path: root/src/CamilStaps/BotleaguesApi/Database/User.php
diff options
context:
space:
mode:
authorCamil Staps2015-05-24 22:42:26 +0200
committerCamil Staps2015-05-24 22:42:26 +0200
commitea7966cc6823ddaa349740e438c4f0cb588f5b32 (patch)
treeab5e2bb9de2b64ee3cdc7d5c0bfbca61ce742335 /src/CamilStaps/BotleaguesApi/Database/User.php
parentUsing email as id; User & PasswordReminder (diff)
User id -> email in other classes
Diffstat (limited to 'src/CamilStaps/BotleaguesApi/Database/User.php')
-rw-r--r--src/CamilStaps/BotleaguesApi/Database/User.php9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/CamilStaps/BotleaguesApi/Database/User.php b/src/CamilStaps/BotleaguesApi/Database/User.php
index 6b0d863..cabd126 100644
--- a/src/CamilStaps/BotleaguesApi/Database/User.php
+++ b/src/CamilStaps/BotleaguesApi/Database/User.php
@@ -23,12 +23,17 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
}
public function validToken($token) {
- return UserToken::where('userId', $this->id)->where('token', $token)->where('valid_till', '>', date("Y-m-d H:i:s"))->count() > 0;
+ $token = UserToken::where('userEmail', $this->email)->where('token', $token)->where('valid_till', '>', date("Y-m-d H:i:s"))->first();
+ if (empty($token)) {
+ return false;
+ }
+ $token->refresh();
+ return true;
}
public function findPasswordReminders($token = null) {
$base = PasswordReminder
- ::where('userId', $this->id)
+ ::where('userEmail', $this->email)
->where('used_at', null)
->where('valid_till', '>', date('Y-m-d H:i:s'));
if ($token == null) {