Skip to content

Commit

Permalink
confirmed with date and block multiple times confirm action
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleymilan committed Oct 9, 2014
1 parent 8b19f79 commit 0b1a8bd
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Confide/EloquentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,18 @@ public function getUserByEmailOrUsername($emailOrUsername)
*
* @param string $code
*
* @return bool Success
* @return bool Success or Null for nothing affected
*/
public function confirmByCode($code)
{
$identity = ['confirmation_code' => $code];

$user = $this->getUserByIdentity($identity);

if ($user) {
if ($user->confirmed == null) {
return $this->confirmUser($user);
} else if ($user) {
return null;
} else {
return false;
}
Expand All @@ -143,7 +145,10 @@ public function confirmByCode($code)
*/
protected function confirmUser($user)
{
$user->confirmed = true;
$date = new \DateTime();
$date->setTimezone(new \DateTimeZone('UTC'));

$user->confirmed = $date->format('Y-m-d H:i:s');

return $user->save();
}
Expand Down

0 comments on commit 0b1a8bd

Please sign in to comment.