This repository has been archived by the owner on Feb 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Callbacks
dre1080 edited this page Feb 20, 2012
·
2 revisions
There are 4 callbacks at various points in the authentication cycle available. Namely:
after_set_user
after_authentication
after_authorization
before_logout
For each callback Warden will send the current user object as an argument.
This is called every time the user is set. The user is set:
- when the user is initially authenticated.
- when the user is set via
Warden::set_user()
.
Warden::after_set_user(function($user) {
logger(\Fuel::L_INFO, 'User '.$user->id.' was set as current user', 'Warden::after_set_user');
});
This is called every time the user is authenticated.
Warden::after_authentication(function($user) {
// Or log some stats to Redis etc..
logger(\Fuel::L_INFO, 'User '.$user->id.' was authenticated successfully at '.$user->current_sign_in_at, 'Warden::after_authentication');
});
This is called every time the user is successfully authorized. The user is authorized when:
-
Warden::can()
is successful. -
Warden::authorize()
is successful.
Warden::after_authorization(function($user) {
logger(\Fuel::L_INFO, 'User '.$user->id.' was successfully authorized to access '.\Input::server('REQUEST_URI'));
});
This is called before each user is logged out.
Warden::before_logout(function($user) {
logger(\Fuel::L_INFO, 'User '.$user->id.' logging out', 'Warden::before_logout');
});