lonnieezell / myth-auth

One-stop Auth package for CodeIgniter 4
MIT License
637 stars 208 forks source link

login after restrictToGroups will not redirect me to same restricted page #529

Closed ArabGenius closed 2 years ago

ArabGenius commented 2 years ago

Hello after putting this code $this->restrictToGroups('admins'); it redirect me to login page with a request_uri like xxxxxxxxxx.test/login?request_uri=http%3A%2F%2Fxxxxxxxxxx.test%2Fadmin yet after putting my admin information and login successfully it redirect me to main page what should I do ?

manageruz commented 2 years ago

Hello ArabGenius

Quick fix is, find in your auth controller's login method this line: $_SESSION['redirect_url'] = session('redirect_url') ?? site_url('/'); and change it to: $_SESSION['redirect_url'] = $this->request->getVar('request_uri') ?? session('redirect_url') ?? site_url('/');

ArabGenius commented 2 years ago

thank you @manageruz it works like charm

manageruz commented 2 years ago

Nice to hear that. Good luck