I have created 2 custom roles for my project. I want to assign a Role to the users during the registration process. How can I assign a role by default to the user during the registration.
Also, how can I create 2 registration forms, if I have 2 different roles. I need 2 types of registrations for different types of roles.
In the
savemethod of yourUserServicePluginimplementation, you can add roles when you create the user. For example, assuming you have a model calledUserthat implements Deadbolt'sSubjectinterface,The
giveRolemethod of is something like this.This assumes you're using Ebean and Java, but the mechanics are the same if you're using Scala or a different database tool.
For having different roles assigned on user creation, move the bit where you assign roles out of the
savemethod and into (for example) the controller methods through which these registrations come.