mercredi 1 novembre 2017

if condition does not end execution?

In my controller, I have a if condition like this

 public function index()
    {
        //if user is logged in 
        if (auth()->guard('web')->check())
        {
            return back()->withMessage('You are not allowed');
        }
      //if not logged in
      long time consuming API call here - takes 1 minute

This logic does not work as intended, as even if you are logged in, it takes one minute to show the message of 'You are not allowed'. Isn't it supposed to check the if condition first and if it matches,end the execution? It should be returning back (if logged in) instantly, but it makes the API call and takes one minute to redirect back.

Am I missing something?

Aucun commentaire:

Enregistrer un commentaire