0

Spring Lemon comes with UNVERIFIED, BLOCKED and ADMIN Roles. I'm refering to the Role interface in the AbstractUser class. What do I do in my code, to have several additionnal roles ?

I need two roles, say TEACHER, and STUDENT, and also to make the user be a student by default on signup.

mozexty
  • 44
  • 1
  • 6

1 Answers1

0

Because roles are nothing but Strings, just defining some more String constants anywhere in your application, say in the concrete User class, should do.

You need to override methods of LemonService to alter its behavior. For adding a STUDENT role to a newly signed up user, just overriding the initUser method should do, I think. The overridden method should call its super, and additionally add a "STUDENT" role to the roles collection.

Sanjay
  • 8,755
  • 7
  • 46
  • 62