authenticationatk4agiletoolkit

How to log Atk4 auth/login event


I'm new to Agile Toolkit and I'm trying to make some sort of trigger/log on user auth.

For example, after successful login, I want to execute some query like:

UPDATE `user_login` SET `user_id` = XXX, `login_date` = NOW();

I've searched documentation and googled for it but still can't find the way to do this.

Thank you!

EDIT: my solution (thank you @DarkSide ;)

In class Frontend:

$this->add('Auth')->setModel('User');

$this->auth->addHook('loggedIn', function($m)
{
    $l = $this->add('Model_User_Login');
    $l['user_id'] = $m->info['id'];
    $l['date'] = date('Y-m-d H:i:s');
    $l->save();
});

Solution

  • See /atk4/lib/Auth/Basic.php class Auth_Basic method loggedIn().

    I guess you can overwrite or extend it to fit your needs.

    There is also a hook called loggedIn.