Sentinel\Repositories\User\SentryUserRepository::activate PHP Méthode

activate() public méthode

Attempt activation for the specified user
public activate ( integer $id, string $code ) : boolean
$id integer
$code string
Résultat boolean
    public function activate($id, $code)
    {
        try {
            // Find the user using the user id
            $user = $this->sentry->findUserById($id);
            // Attempt to activate the user
            if ($user->attemptActivation($code)) {
                // User activation passed
                $this->dispatcher->fire('sentinel.user.activated', ['user' => $user]);
                // Generate login url
                $url = route('sentinel.login');
                return new SuccessResponse(trans('Sentinel::users.activated', array('url' => $url)), ['user' => $user]);
            }
            return new FailureResponse(trans('Sentinel::users.notactivated'), ['user' => $user]);
        } catch (UserNotFoundException $e) {
            $message = trans('Sentinel::sessions.invalid');
            return new ExceptionResponse($message);
        } catch (UserAlreadyActivatedException $e) {
            $message = trans('Sentinel::users.alreadyactive');
            return new ExceptionResponse($message);
        }
    }