Skip to content

Commit

Permalink
[5.2] Use Carbon for everything time related in DatabaseTokenReposito…
Browse files Browse the repository at this point in the history
…ry (#13234)

* Use Carbon for everything time related

Fixes timezone issues where my token had been expired for an hour already as soon as they were issued.
App timezone was CET and token expiry set to 60 minutes.

* Use $expiresAt->isPast()

Thanks for advice @acasar
  • Loading branch information
annejan authored and taylorotwell committed Apr 21, 2016
1 parent 0d356a6 commit c16f026
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/Illuminate/Auth/Passwords/DatabaseTokenRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,9 @@ public function exists(CanResetPasswordContract $user, $token)
*/
protected function tokenExpired($token)
{
$expirationTime = strtotime($token['created_at']) + $this->expires;
$expiresAt = Carbon::parse($token['created_at'])->addSeconds($this->expires);

return $expirationTime < $this->getCurrentTime();
}

/**
* Get the current UNIX timestamp.
*
* @return int
*/
protected function getCurrentTime()
{
return time();
return $expiresAt->isPast();
}

/**
Expand Down

0 comments on commit c16f026

Please sign in to comment.