Myth:Auth Helper usage - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Addins (https://forum.codeigniter.com/forumdisplay.php?fid=34) +--- Thread: Myth:Auth Helper usage (/showthread.php?tid=75340) |
Myth:Auth Helper usage - paul - 01-28-2020 i am testing the Myth:Auth module and i have a issue with the helper "auth" i use the helper fonction logged_in() in the top banner of my layout template it work fine in all my pages but in the login page (which is load by the Myth:Auth module) the helper fonction isn't found "Call to undefined function logged_in()" RE: Myth:Auth Helper usage - MGatner - 01-28-2020 You need to load the helper first. Likely you are doing that in your Controller, in the “helpers” property, but since the login endpoint is actually part of a Myth controller it is not available. It might make sense for the Myth Controllers all to load the helper (you could open an issue on GitHub). In the meantime a quick fix would be to load the helper in your layout: helper(‘auth’) RE: Myth:Auth Helper usage - InsiteFX - 01-28-2020 Or load it in a BaseController and then extend all your Controllers from the BaseController. RE: Myth:Auth Helper usage - paul - 01-28-2020 ok Thx mgatner InsiteFX: the controller of the login page don't exdend of BaseController because he is inside the Myth:Auth package RE: Myth:Auth Helper usage - InsiteFX - 01-29-2020 It can still extend from it. use App\Controllers\BaseController; RE: Myth:Auth Helper usage - arnezthe - 03-09-2020 I have the same issue with this. The auth_helper can't call from layout view although I have try to add to the BaseController protected $helpers = ['html','auth'] or from public function __construct(); and try another one from the AuthController helper('auth') or helper('Myth\Auth\auth') How to solves this issue? RE: Myth:Auth Helper usage - arnezthe - 03-09-2020 I solve this by called this auth helper at the view file.. helper('auth'); Any other solution? RE: Myth:Auth Helper usage - MGatner - 03-13-2020 Loading a helper is essentially just calling “require_once path/to/filename.php”. If you are planning to use this on every page load you could add that to app/Common.php. Another good place would be in any filters you use that rely on auth_helper (I believe this change was already made to the Myth filters) |