Devise\Users\Sessions\SessionsRepository::activate PHP Method

activate() public method

Process user activation request.
public activate ( integer $userId, string $activateCode ) : False | DeviseUser
$userId integer
$activateCode string
return False | DeviseUser | DeviseUser
    public function activate($userId, $activateCode)
    {
        $user = $this->UsersRepository->findById($userId);
        if ($activateCode === $user->activate_code) {
            $this->UserManager->activate($user);
            // activate the user
            $this->Auth->login($user);
            // auto-login newly activated user
            $this->message = 'Account successfully activated.';
            return true;
        }
        $this->message = 'Issues occurred while attempting to activate account. Please contact support.';
        return false;
    }

Usage Example

Beispiel #1
0
 /**
  * Executes activate method in SessionsRe.
  *
  * @param  integer  $userId
  * @param  string  $activateCode  Hashed activate_code value in db
  * @return Response
  */
 public function requestActivation($userId, $activateCode)
 {
     if ($this->SessionsRepository->activate($userId, $activateCode)) {
         return $this->Redirect->route('dvs-dashboard')->with('message', $this->SessionsRepository->message);
     }
     return $this->Redirect->route('dvs-user-login')->withInput()->withErrors($this->SessionsRepository->errors)->with('message-errors', $this->SessionsRepository->message);
 }