Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.kpksoftware.domain;
- import lombok.Getter;
- import org.springframework.security.authentication.LockedException;
- import org.springframework.security.core.authority.AuthorityUtils;
- import static com.kpksoftware.util.Constants.LOCKED_ACCOUNT_MESSAGE;
- @Getter
- public class CurrentUser extends org.springframework.security.core.userdetails.User {
- private User user;
- public CurrentUser(User user) {
- super(user.getEmail(), user.getPassword(), AuthorityUtils.createAuthorityList(user.getRole().toString()));
- this.user = user;
- }
- public boolean isAccountNonLocked() {
- if (!user.isActive()) {
- throw new LockedException(LOCKED_ACCOUNT_MESSAGE);
- }
- return true;
- }
- public User getUser() {
- return user;
- }
- public Long getId() {
- return new Long(user.getId());
- }
- public Role getRole() {
- return user.getRole();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement