CodeIgniter Forums
Shield Authentication Actions Customize - 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: Shield Authentication Actions Customize (/showthread.php?tid=90522)



Shield Authentication Actions Customize - TakonSix - 03-30-2024

Hi,
i am trying on a new composer install Codeigniter & Shield to include a new Authentication Action "activate by admin".
First i try to copy EmailActivator named it AdminActivator and delete the email part and the createCodeIdentity.
But i ended in a 404!
Then i try copy EmailActivator named it AdminActivator and delete the email part and add to show function
PHP Code:
$this->deleteIdentity($user); 
and create the function
PHP Code:
private function deleteIdentity(User $user)
    {
        /** @var UserIdentityModel $identityModel */
        $identityModel model(UserIdentityModel::class);
        $identityModel->deleteIdentitiesByType($user$this->type);
    
This works but!

Now i wanna make this secure for any updates of Shield. So i make some folder under App (Authentication/Actions) and place there my new AdminActivator.php
In App/Config/Auth.php 
PHP Code:
public array $actions = [
        'register' => \Authentication\Actions\AdminActivator::class,
        'login'    => null,
    ]; 
And voila i get this error 
Code:
Call to a member function createIdentity() on null
VENDORPATH/codeigniter4/shield/src/Authentication/Authenticators/Session.php at line 209

what am i missing?