shield: Bug: Missing loading helper 'auth' in ActionController

PHP Version

7.4.16

CodeIgniter4 Version

4.2.3

Shield Version

v1.0.0-beta.2

Which operating systems have you tested for this bug?

Windows

Which server did you use?

apache

Database

mysqlnd 8.1.1

Did you customize Shield?

No

What happened?

We’ve wanted to enable 2FA authentication in our application, but after enabling it in Auth.php an error occurs.

Steps to Reproduce

Enable 2FA in Auth.php with this code public array $actions = [ 'login' => 'CodeIgniter\Shield\Authentication\Actions\Email2FA', 'register' => null, ];

After user login, system is returning error image

After some reading of Shield code we’ve seen that the ActionController actually don’t load an auth helper. So that’s why Codeigniter is trying to run auth() controller, what we see on the screenshot.

Please update ActionController and change protected $helpers = ['setting']; to protected $helpers = ['auth', 'setting'];

Expected Output

image

Anything else?

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (17 by maintainers)

Most upvoted comments

@MGatner I’ve maded a pull request by Github UI

In Common.php, developers can override the helper functions. So I sent a PR #368

Okay maybe I was wrong on which event, but same idea:

/**
 * Loads helpers we want available globally.
 *
 * @see BaseAction::__construct() and BaseController::$helpers for slightly less global
 */
Events::on('post_controller_constructor', static function () {
    helper(['alerts', 'auth', 'html', 'preferences', 'themes']);
});