Override default backend sign in behavior
Often times we need to tie into the signin flow for the Backend. This is common when trying to support SSO, or authenticating with LDAP/AD mechanisms.
This trick shows you how to do this by overriding the Backend Controller's sign in method. The Trick "Re-use and migrate WordPress password hashes in October" shows you an alternative approach by overriding October's AuthManager class (see steps 3 and 4 of the Trick).
You can override the default signin behavior for the backend with a fairly simple addition to your plugin's boot()
method:
/*
* Override default sign in behavior
*/
Event::listen('backend.page.beforeDisplay', function ($controller, $action) {
if(!$controller instanceof \Backend\Classes\Controller) {
return;
}
if ($action == 'signin') {
try {
if (post('postback')) {
return $this->signin_onSubmit();
}
} catch (Exception $ex) {
Flash::error($ex->getMessage());
}
}
});
That's pretty much all there is to it. Obviously the logic for the sign in behavior will need to be implemeneted per your requirements, but the possibilities are limitless.
Nice clear explanation. Can I suggest you provide a real world example of how you would solve a specific problem with this technique? I think it would be helpful to people who are still on the fence about building a site with October.
hi @douggough, thanks for the reply! I'll be blogging soon about how I use these tricks to develop custom october apps, stay tuned! You can also follow me on twitter @thegreatbarker for my latest announcements.