src/AuthManager.php
public function activate($code)
    {
        try {
            // Attempt to fetch the user via the activation code
            $activation = $this->activations
                           ->createModel()
                           ->newQuery()
                           ->where('code', $code)
                           ->where('completed', false)
                           ->where('created_at', '>', Carbon::now()->subSeconds(259200))
                           ->first();

            if (!$activation) {
                $message = $this->translate("activation_problem", "Invalid or expired activation code.");
                throw new InvalidArgumentException($message);
            }
            $user = $this->sentinel->findUserById($activation->user_id);

            // Complete the user's activation
            $this->activations->complete($user, $code);

            // While we are here, lets remove any expired activations
            $this->activations->removeExpired();
        } catch (Exception $e) {
            return $this->returnException($e);
        }

        if ($user) {
            $message = $this->translate("activation_success", "Activation successful.");
            return new SuccessReply($message);
        }

        $message = $this->translate('activation_failed', 'There was a problem activating your account.');
        return new FailureReply($message);
    }
public function activate($code)
    {
        try {
            // Attempt to fetch the user via the activation code
            $activation = $this->activations
                           ->createModel()
                           ->newQuery()
                           ->where('code', $code)
                           ->where('completed', false)
                           ->where('created_at', '>', Carbon::now()->subSeconds(259200))
                           ->first();

            if (!$activation) {
                $message = $this->translate("activation_problem", "Invalid or expired activation code.");
                throw new InvalidArgumentException($message);
            }
            $user = $this->sentinel->findUserById($activation->user_id);

            // Complete the user's activation
            $this->activations->complete($user, $code);

            // While we are here, lets remove any expired activations
            $this->activations->removeExpired();
        } catch (Exception $e) {
            return $this->returnException($e);
        }

        if ($user) {
            $message = $this->translate("activation_success", "Activation successful.");
            return new SuccessReply($message);
        }

        $message = $this->translate('activation_failed', 'There was a problem activating your account.');
        return new FailureReply($message);
    }
public function activate ( $ code ) { try { // Attempt to fetch the user via the activation code $ activation = $ this -> activations -> createModel ( ) -> newQuery ( ) -> where ( 'code' , $ code ) -> where ( 'completed' , false ) -> where ( 'created_at' , '>' , Carbon :: now ( ) -> subSeconds ( 259200 ) ) -> first ( ) ; if ( ! $ activation ) { $ message = $ this -> translate ( "activation_problem" , "Invalid or expired activation code." ) ; throw new InvalidArgumentException ( $ message ) ; } $ user = $ this -> sentinel -> findUserById ( $ activation -> user_id ) ; // Complete the user's activation $ this -> activations -> complete ( $ user , $ code ) ; // While we are here, lets remove any expired activations $ this -> activations -> removeExpired ( ) ; } catch ( Exception $ e ) { return $ this -> returnException ( $ e ) ; } if ( $ user ) { $ message = $ this -> translate ( "activation_success" , "Activation successful." ) ; return new SuccessReply ( $ message ) ; } $ message = $ this -> translate ( 'activation_failed' , 'There was a problem activating your account.' ) ; return new FailureReply ( $ message ) ; }
Activate a user based on the provided activation code
@param  string $code
@return Reply
Activate a user based on the provided activation code