Welcome Guest, Not a member yet? Register   Sign In
Myth:Auth Helper usage
#1

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()"
Reply
#2

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’)
Reply
#3

Or load it in a BaseController and then extend all your Controllers from the BaseController.
What did you Try? What did you Get? What did you Expect?

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

ok  Thx mgatner

InsiteFX: the controller of the login page don't exdend of BaseController because he is inside the Myth:Auth package
Reply
#5

(This post was last modified: 01-29-2020, 03:36 AM by InsiteFX.)

It can still extend from it.

use App\Controllers\BaseController;
What did you Try? What did you Get? What did you Expect?

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

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?
Reply
#7

I solve this by called this auth helper at the view file.. helper('auth'); Any other solution?
Reply
#8

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)
Reply




Theme © iAndrew 2016 - Forum software by © MyBB