This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
I am creating a plugin for october and need to write some functionality on backend user logout. I have seen that there is a event for user login which words perfectly.
Event::listen('backend.user.login', function($user) { //Code Here });
I have gone through the documentation and was unable to find any such event. Is there any similar event for logout? If not how can I achieve this.?
Last updated
Interesting...
I need the same functionality myself. There apparently is no such event :(
The API documentation for the login event is located at:
https://octobercms.com/docs/api/backend/user/login
The API documentation for all other system events is located at:
https://octobercms.com/docs/api (look for Events in the side menu)
The Model firing the event: https://github.com/octobercms/october/blob/develop/modules/backend/models/User.php
The controller (backend/auth/{function_name}: https://github.com/octobercms/october/blob/develop/modules/backend/controllers/Auth.php
Issue on GitHub
https://github.com/octobercms/october/issues/3864
Contribution of Luke Towers on Github:
https://github.com/LukeTowers/oc-pwnedpasswords-plugin/blob/master/Plugin.php
Alternative for the missing event
If you study the logout link for backend users you will find that it directs to a page (/backend/backend/auth/signout
).
The following code is tested and works (place inside your own Plugin.php
):
(...)
use Backend\Controllers\Auth;
class Plugin extends PluginBase
{
public $elevated = true;// important
public function boot()
{
Auth::extend(function ($controller) {
$controller->bindEvent('page.beforeDisplay', function ($action, $params) use ($controller) {
if ($action === 'signout') {
Log::info('signing out...');
}
});
});
}
(...)
Last updated
1-2 of 2