About IonAuth 4 auth System |
I'm working on a project based on codeigniter 4 and IonAuth
- I used a IonAuth library as Auth System and included it in BaseController successfully using: $this->ionAuth = new \IonAuth\Libraries\IonAuth(); - After that i make my Auth controller extends BaseController without problems. The question is: When I check the login in __construct function of any controller I get Call to a member function loggedIn() on null error. - when i add $this->ionAuth = new \IonAuth\Libraries\IonAuth(); in __construct function even though I called him in BaseController before, Error is gone but loggedIn() don't work . PHP Code: <?php namespace App\Controllers; To avoid the error I have to call if (!$this->ionAuth->loggedIn()) at all controll methodes like this: PHP Code: <?php namespace App\Controllers; I think that's ugly way, any Solutions please?? Thanks.
I believe that you are making some confusion...
Try to keep it simple... Just load the library in method and BE HAPPY ! Ion Auth is meant to be simple... PHP Code: public function addNewRecord()
I try create full support with CI4: https://github.com/benedmunds/CodeIgnite.../pull/1384
(11-09-2019, 02:08 PM)Poetawd Wrote: I believe that you are making some confusion... But suppose you have logged in and that you want to send a message notifying the user that he does not have access to certain system functionality. Inicio Controller: PHP Code: public function ErrorDeAcceso(){ Usuarios Controller: PHP Code: public function VerSiUsuarioTieneAccesoAlaOpcion($id_modulo_opcion){ When invoking PHP Code: $this->VerSiUsuarioTieneAccesoAlaOpcion(700); I did not redirect myself to the respective controller, but it continues to execute what follows after PHP Code: $this->VerSiUsuarioTieneAccesoAlaOpcion(700); something wrong?
You have to create a filter in App -> Filters, something like :
PHP Code: <?php Then to apply it, modify the config in App -> Config -> Filters like this : PHP Code: [quote pid='369076' dateline='1572757201']
(11-02-2019, 10:00 PM)adelbak Wrote: - After that i make my Auth controller extends BaseController without problems. Hi everybody. Is there anyone here who can clarify me the need of creating my own Auth controller extending the Basecontroller? Just to customize views? Thanks in advance!
[Image: https://vulndetect.org/assets/uploads/fi...docker.ico]
Andy Biancoblu Quote:Once you have eliminated the impossible, whatever remains, however improbable, must be the truth. |
Welcome Guest, Not a member yet? Register Sign In |