irankhosravi
2 months ago

How to login after enter verification code in laravel?

Posted 2 months ago by irankhosravi

We have a page with a verification code that redirects to this page after the user logs in. I want to login after clicking the user confirmation button.

code

public function send(Request $request)
{
    $user = User::whereCode($request->code)->whereMobile($request->mobile)->first();
    if($user){
        $user->verification_code = 1;
        $user->save();
        
        $this->validator($request->all())->validate();

        event(new Registered($user = $this->create($request->all())));

        $this->guard()->login($user);

        return $this->registered($request, $user)
                ?: redirect($this->redirectPath());
        
    } else {
        return redirect()->back();
    }
}

Please sign in or create an account to participate in this conversation.