I want to make sure I am not re-inventing the wheel or heading down a silly path here.

I have to implement a "user area" on a larger site for a specific sub-set of user roles. I have created a custom module to manage some routing and and admin features of this.

One specific change I wish to make is a custom login and account page and set of associated routes. For example, rather than /user/login users login at /private/login and rather than /user/{id} they are directed to /private/user/{id} which I can then style with a different template.

To achieve this I have started extending specific forms and controllers and routes from the core/user module. Is this a sensible approach or is there an easier way to achieve this? In the worse case I could end up re-implementing core/user with minimal changes, which seems excessive.

EDIT - This has been marked as a duplicate of this question. However, unlike that question I do not wish to override ALL user routes. I want the default ones to remain intact. I have created my own secondary custom login page. Once logged in I want those users to be sent to a specific set of user pages that differs from the default set but I want the regular pages to remain.

More specifically I would like to restrict the routes available by user role.

An admin user could log in anywhere and go to /user/{id}. A 'volunteer' could log in and be taken to a "volunteer" user page with the path: /volunteer/user/{id}. I plan on adding at least one other type of user and user page in the future so there should be three sets of user paths and routes available.

  • You can simply redirect the user where you want to after login based on their user role. I fail to see the need for additional login form that is role-specific, makes no sense really. – user21641 Jul 10 '17 at 6:43
  • The login form need not be different. At first I wanted to control the available routes based on the specific login form a user came in via but it is the same to me if I can control the user via role. I do wish have several sets of user routes however depended on the user role. Sorry if I am explaining this poorly. – tanbog Jul 10 '17 at 7:00
  • But you cannot have login form based on user role since you do not know the user role before the user actually logs in. – user21641 Jul 10 '17 at 8:28
  • ^ this. Plus it's just not practical changing all these routes and multiple login forms. – Kevin Jul 10 '17 at 10:35
  • It may not be practical, but you can if you want. Register as many user routes with different url's as you like and redirect to them once the user has logged in. Restricting by user roles is a simple permission/access for the route. It is not much left to answer here. – 4k4 Jul 10 '17 at 11:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.