[SOLVED] Different role with Sandstorm.Usermanagement package

Is it possible to use different role for different login/registration form using Sandstorm.Usermanagement ?

I currently use this package with one role and want to add another one, something like “owner” and ’member” role.

The goal is to have 2 different login and registration form and handle role and redirect with user role.

Any idea or approach is welcome !

Hey Jonathan, you could roll your own UserCreationService, very similar to the default NeosUserCreationService. You can then create different types of registration forms extending/inheriting from the default one, and add a hidden field that writes something into the “additionalAttributes” of the RegistrationFlow object. You can then read in your custom UserCreationService and assign a member/owner role based on that value.

As for the login form, it does not matter what roles your users have - you just get logged in if you have an account, and you’re assigned the authorizations that come with your roles. The only thing you could customize there is where users are redirected after login based on their role, and you can do that by creation your own implementation of the RedirectTargetServiceInterface.

1 Like