Using shield, How i can redirect to separate url if the user not in admin group - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Using shield, How i can redirect to separate url if the user not in admin group (/showthread.php?tid=88262) Pages:
1
2
|
Using shield, How i can redirect to separate url if the user not in admin group - sknair143 - 08-15-2023 Hello, I'm working with codeigniter shield package for authorization and i want to restrict normal user to access the administration controllers which is not in admin group. but everything works perfect, it redirects to index page if the user not in admin group. but i want to to redirect them to seperate page instead of redirecting to the index page. Below is my code in Routes.php Code: $routes->group("admin", ["namespace" => "\Admin\Controllers", "filter" => "group:admin"], static function ($routes) { How i can redirect to seperate page ? Thanks RE: Using shield, How i can redirect to separate url if the user not in admin group - InsiteFX - 08-15-2023 CodeIgniter 4 Shield User Guide - Authentication Flow RE: Using shield, How i can redirect to separate url if the user not in admin group - datamweb - 08-15-2023 We have the following solution to transfer the user if he belongs to a certain group or permission, after login. But I think that is not what you mean. https://codeigniter4.github.io/shield/customization/#customize-login-redirect What I understand is that you want the following feature to be added to the shield. https://github.com/codeigniter4/shield/pull/589#issuecomment-1375755217 RE: Using shield, How i can redirect to separate url if the user not in admin group - sknair143 - 08-16-2023 I tried afterPermissionDenied but that does not work Everything works and showing the error " You do not have the necessary permission to perform the desired operation." if the user is not admin and accessing the administrator routes. but i want to change the redirect index to other routes. RE: Using shield, How i can redirect to separate url if the user not in admin group - datamweb - 08-16-2023 (08-16-2023, 12:08 AM)sknair143 Wrote: I tried afterPermissionDenied but that does not work This feature has not been added to the shield yet, as we have not had a request. RE: Using shield, How i can redirect to separate url if the user not in admin group - sknair143 - 08-16-2023 (08-15-2023, 11:26 PM)datamweb Wrote: We have the following solution to transfer the user if he belongs to a certain group or permission, after login. But I think that is not what you mean. (08-16-2023, 01:30 AM)datamweb Wrote:(08-16-2023, 12:08 AM)sknair143 Wrote: I tried afterPermissionDenied but that does not work How i can do this another way i just using filter=>"group:admin" inb routes RE: Using shield, How i can redirect to separate url if the user not in admin group - datamweb - 08-16-2023 (08-16-2023, 01:33 AM)sknair143 Wrote: How i can do this another way i just using filter=>"group:admin" inb routes See: https://github.com/codeigniter4/shield/pull/535#discussion_r1046458048 By changing: https://github.com/codeigniter4/shield/blob/78cac5485ff92a51743fe0f84e561c25add3d5e4/src/Filters/AbstractAuthFilter.php#L41 RE: Using shield, How i can redirect to separate url if the user not in admin group - sknair143 - 08-16-2023 (08-16-2023, 01:46 AM)datamweb Wrote:(08-16-2023, 01:33 AM)sknair143 Wrote: How i can do this another way i just using filter=>"group:admin" inb routes So if i change directly to the core file it will get removed if future updates come in the package right ? RE: Using shield, How i can redirect to separate url if the user not in admin group - datamweb - 08-16-2023 Yes exactly, for this reason it is not recommended to do this. RE: Using shield, How i can redirect to separate url if the user not in admin group - sknair143 - 08-16-2023 (08-16-2023, 02:01 AM)datamweb Wrote: Yes exactly, for this reason it is not recommended to do this.So there is any other solution ? |