daily pastebin goal
25%
SHARE
TWEET

Untitled

a guest Oct 20th, 2018 62 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. use Backend;
  2. use System\Classes\PluginBase; as PluginBase;
  3. use Event;
  4. use BackendAuth;
  5. use Session;
  6. use Illuminate\Support\Facades\Redirect;
  7.  
  8. class Plugin extends PluginBase
  9. {
  10.     public function boot()
  11.     {
  12.         // ......
  13.         // save in session that need redirect
  14.         // because in this event can't do redirect
  15.         Event::listen('backend.user.login', function($model) {
  16.             foreach (BackendAuth::getUser()->roles as $role) {
  17.                 if ($role->code === 'admin') {  // for example redirect only for admins
  18.                     Session::put('redirectAfterLogin', '/backend/some/url');
  19.                 }
  20.             }
  21.         });
  22.  
  23.         Event::listen('backend.page.beforeDisplay', function($controller, $action, $params) {
  24.             // .....
  25.             if ($redirectAfterLogin = Session::pull('redirectAfterLogin', null)) {
  26.                 return Redirect::to($redirectAfterLogin); // do redirect
  27.             }
  28.         });
  29.        
  30.         // .....
  31.     }
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top