User specific route after login


#1

Hi.

Would it be possible to route and lock a user group to the specific collection after login? For example, a blog author would skip Dashboard and get routed to the Blog collection entries list without a possibility to browse anywhere else.
I’m not saying that Dashboard is not user-friendly but there are types of end users that need the simplest possible solutions.

Cheers.


#2

Yes, it should be possible by rebinding existing routes

$app->on('admin.init', function() {
    $this->bind('/', function(){
        return $this->invoke('My\\Custom\\Controller', 'index');
    });
    $this->bind('/cockpit/dashboard', function(){
        return $this->invoke('My\\Custom\\Controller', 'index');
    });
});

or hooking into the admin.dashboard.widgets trigger, e.g.:

$app->on('admin.init', function() {
  $this->on('admin.dashboard.widgets', function($widgets) {
    // provide your logic regarding user group
    $this->reroute('/my-collections');
  });
});

But tbh, if you need something very custom build an admin UI on top of Cockpit, or better, rethink if you really need to cover those situations, users can be trained to use Cockpit ui and comparing with other CMS’s its miles ahead in terms of usability and simplicity.


#3

Thank you @pauloamgomes for your time and effort. I was just trying to provide my client with the simplest way to manage their news by jumping directly into News collection after login.

Cheers.


#4

There are two more options. Add cockpit.start: /collections/entries/news to config.yaml - but this is global for all users.

Or instead of invoking, just redirect on / in bootstrap.php:

$app->on('admin.init', function() {
    $this->bind('/', function(){
        $this->reroute('/collections/entries/news');
    });
});

This is the default:


#5

Thank you @raffaelj, I’ll give it a try.