Welcome Guest, Not a member yet? Register   Sign In
return error from form
#5

(07-23-2020, 08:45 AM)InsiteFX Wrote: Your very welcome.

A lot of us on here are using it, I use it with Boilerplate which is AdminLTE 3 backend Dashboard.
and I' am adding my Blog into it now.

Yes I'm getting on with it very well.      Just one question though? 

When I login the user I set additional session data (AuthController::attemptLogin), this works very well.

However, if session expires and user is still logged in ($this->auth->check()) I need to add the additional session data again.

PHP Code:
public function login()
    {
        
// No need to show a login form if the user
        // is already logged in.
        
        
if ($this->auth->check())
        {    
            
//get my data
            //add data to session - this->session->set($data);
            
            
            
$redirectURL session('redirect_url') ?? '/';
            unset(
$_SESSION['redirect_url']);

            return 
redirect()->to($redirectURL);
        }

            // Set a return URL if none is specified
            $_SESSION['redirect_url'] = session('redirect_url') ?? previous_url() ?? '/';

        return 
view($this->config->views['login'], ['config' => $this->config]);
    } 


So I tried to configure a filter to check the session data exists and if not, redirect to login. But I get caught in an infinite loop.

Filter
PHP Code:
public function before(RequestInterface $request) {    
        
$auth service('session');
        
$uri service('uri');;
        
        
            if(
$uri->getPath!='login' 
                        {

                if (!
$auth->get('user_id') )
                {
                return 
redirect('login');
                }
            }
    

I'm not sure why because if I type http://mysite/login direct into browser, all is OK

Any ideas?
Reply


Messages In This Thread
return error from form - by 68thorby68 - 07-23-2020, 03:00 AM
RE: return error from form - by InsiteFX - 07-23-2020, 03:16 AM
RE: return error from form - by 68thorby68 - 07-23-2020, 03:50 AM
RE: return error from form - by InsiteFX - 07-23-2020, 08:45 AM
RE: return error from form - by 68thorby68 - 07-23-2020, 01:02 PM
RE: return error from form - by InsiteFX - 07-24-2020, 08:06 AM
RE: return error from form - by 68thorby68 - 07-24-2020, 11:10 AM
RE: return error from form - by InsiteFX - 07-24-2020, 12:08 PM



Theme © iAndrew 2016 - Forum software by © MyBB