Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Role cannot create #2

Open
ahheaSK opened this issue Mar 26, 2024 · 3 comments
Open

Role cannot create #2

ahheaSK opened this issue Mar 26, 2024 · 3 comments

Comments

@ahheaSK
Copy link

ahheaSK commented Mar 26, 2024

Role cannot create by code.
but insert direct in database it okay.
You have some config on it.

ServiceImpl
@OverRide
public Role create(Role role) {
// TODO Auto-generated method stub
return roleRepository.save(role);
}

@chijioke-ibekwe
Copy link
Owner

Hi @ahheaSK . What error do you get when you try to insert a new role programmatically? If you can paste the stacktrace that would be great

@ahheaSK
Copy link
Author

ahheaSK commented Mar 27, 2024 via email

@chijioke-ibekwe
Copy link
Owner

chijioke-ibekwe commented Mar 29, 2024

@ahheaSK I'm guessing the issue is from the role name which is supposed to be an enum and uses the RoleNameConverter. Change the type of the name attribute on the role entity from RoleName enum to String. You would also need to go to line 23 on the Mapper class and change this:
authorities.add(new SimpleGrantedAuthority(r.getName().getValue()));
to this:
authorities.add(new SimpleGrantedAuthority(r.getName()));

Let me know how it goes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants