Welcome Guest, Not a member yet? Register   Sign In
Shield problem redirecting in hosting
#1

(This post was last modified: 06-13-2025, 07:39 AM by pippuccio76.)

Hi , i have an application that work fine in localhost .

I upload file on hosting but when i try to login with shield it return on login page without error message , if i see log i have : 

INFO - 2025-06-13 15:53:33 --> REDIRECTED ROUTE at https://mysite.it/login

it seem that not save user session:
__ci_last_regenerate|i:1749823269;csrf_test_name|s:32:"06d7c9016ed344db8ac20881c5c05d79";_ci_previous_url|s:38:"https://mysite.it/index.php/login";

wath can i do ?
Reply
#2

i try debug , i insert in  LoginController in the method loginAction
a log:
log_message('info', 'Inside login action');
but in log there isn't this message it seem that does'nt redirect to login  action...
Reply
#3

inspect your permission and user group. Lever shield: use these
Codeigniter First, Codeigniter Then You!!
yekrinaDigitals

Reply
#4

(06-13-2025, 07:07 PM)luckmoshy Wrote: inspect your permission and user group. Lever shield: use these



I don't tink it's a permission problem ,

this is method in config/auth

Code:
    public function loginRedirect(): string
    {
        $session = session();
        $url    = $session->getTempdata('beforeLoginUrl') ?? setting('Auth.redirects')['login'];



        if (auth()->user()->can('admin.access')) {

            //log_message('info', 'permission:admin.access');

            $url = '/admin/dashboard';

            return $this->getUrl($url);

        } elseif (auth()->user()->can('user.access')) {

            //log_message('info', 'permission:agente.access');

            $url = '/user/dashboard';

            return $this->getUrl($url);
        }
       
        return $this->getUrl($url);
    }

and this is route :

Code:
$routes->group('admin', ['filter' => 'permission:admin.access', 'namespace' => 'App\Controllers\Admin'], function ($routes) {

    $routes->get('dashboard', 'Admin::dashboard');
});

in db i have two user 1 superadmin 1 admin

i try to remove  'filter' => 'permission:admin.access',  but it redirect always on login
Reply
#5

Is the session set? Also, this line looks unnecessary:
PHP Code:
$url    $session->getTempdata('beforeLoginUrl') ?? setting('Auth.redirects')['login']; 
Here is a loginredirect that I am using:

PHP Code:
public function loginRedirect(): string
{
$url auth()->user()->inGroup('user''superadmin''admin')
'/admin'
setting('Auth.redirects')['login'];

return 
$this->getUrl($url);

Reply
#6

(This post was last modified: 06-18-2025, 09:43 PM by InsiteFX.)

Check your Auth.php Config file and check your redirects in it.

Also make sure that your time zone is set correct.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#7

(06-14-2025, 02:02 AM)InsiteFX Wrote: Check your Auth.php Config file and check your redirects in it.

Also make sure the your time zone is set correct.

this is the time :

    public string $appTimezone = 'Europe/Rome';

the auth redirect is posted over:

Code:
    public function loginRedirect(): string
    {
        $session = session();
        $url    = $session->getTempdata('beforeLoginUrl') ?? setting('Auth.redirects')['login'];
       
        log_message('info', 'Auth::loginRedirect: ' . $url);

        $url = '/admin/dashboard';

        if (auth()->user() ) {

            log_message('info', 'User logged');

        }else{

            log_message('info', 'User not logged');
        }


        if (auth()->user()->can('admin.access')) {

            log_message('info', 'permission:admin.access');

            $url = '/admin/dashboard';

            return $this->getUrl($url);

        } elseif (auth()->user()->can('user.access')) {

            log_message('info', 'permission:agente.access');

            $url = '/user/dashboard';

            return $this->getUrl($url);
        }
       
        return $this->getUrl($url);
    }

but it seem doesn't work login : 

INFO - 2025-06-14 12:25:46 --> Inside login view
DEBUG - 2025-06-14 12:25:46 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.

i don't have in log User logged or user not logged
Reply
#8

Did you check the loginAttemps table to see if they were logged in?

Note

This redirect happens after the specified action is complete. In the case of register or login, it might not happen
immediately. For example, if you have any Auth Actions specified, they will be redirected when those actions are
completed successfully. If no Auth Actions are specified, they will be redirected immediately after registration or
login.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#9

Also check in Config\app.php the uriProtocol you may try different ones sometimes this can cause problems
if not set correctly.

PHP Code:
/**
  * --------------------------------------------------------------------------
  * URI PROTOCOL
  * --------------------------------------------------------------------------
  *
  * This item determines which server global should be used to retrieve the
  * URI string. The default setting of 'REQUEST_URI' works for most servers.
  * If your links do not seem to work, try one of the other delicious flavors:
  *
  *  'REQUEST_URI': Uses $_SERVER['REQUEST_URI']
  * 'QUERY_STRING': Uses $_SERVER['QUERY_STRING']
  *    'PATH_INFO': Uses $_SERVER['PATH_INFO']
  *
  * WARNING: If you set this to 'PATH_INFO', URIs will always be URL-decoded!
  */
 
public string $uriProtocol 'REQUEST_URI'
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB