Ben
Ben

Reputation: 353

How to override Sentinel Activation (using Laravel)

For the most part, I want all users to have to use the activation checkpoint when registering for my site.

There are some occasions where I would like to bypass this, some thing like

Activation::setToTrue($user);

Is there a good way to do this that you know of?

Thanks

Ben

Upvotes: 0

Views: 1320

Answers (2)

Sohel0415
Sohel0415

Reputation: 9853

Try this to activate on registration using sentinel-

Sentinel::registerAndActivate();

Or you could do this like following by bypassing existing user object. First you need to check if any activation record exists for this user or not. Then do the necessary steps to complete the activation according to your need.

$activation = \Cartalyst\Sentinel\Laravel\Facades\Activation::exists($user);
if($activation){
    Activation::complete($user, $activation->code);
}
else{
    $activation2 = Activation::create($user);
    Activation::complete($user, $activation2->code);
}

Upvotes: 0

Ben
Ben

Reputation: 353

Actually I have to register them first, then if they have a mobile, I'm using Nexmo to validate and then if that succeeds I need to override the activation but without knowing the code (because I obviously don't want to store on the session).

So I've ended up with this crude solution which can't be right can it?

        \Activation::remove($user);
        $activation = \Activation::create($user);
        \Activation::complete($user, $activation['code']);

Upvotes: 1

Related Questions