mirror of
https://github.com/FatttSnake/Pinnacle-OA.git
synced 2026-04-06 07:21:24 +08:00
Added back-end permission verification
This commit is contained in:
@@ -9,6 +9,9 @@ import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import com.cfive.pinnacle.entity.permission.Element;
|
||||
import com.cfive.pinnacle.entity.permission.Menu;
|
||||
import com.cfive.pinnacle.entity.permission.Operation;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
@@ -65,6 +68,15 @@ public class User implements Serializable {
|
||||
@TableField(exist = false)
|
||||
private List<Group> groups;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<Menu> menus;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<Element> elements;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<Operation> operations;
|
||||
|
||||
@TableField("deleted")
|
||||
private Long deleted;
|
||||
|
||||
|
||||
@@ -6,20 +6,38 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class LoginUser implements UserDetails {
|
||||
private User user;
|
||||
@JsonIgnore
|
||||
private List<GrantedAuthority> authorities;
|
||||
|
||||
public LoginUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Collection<? extends GrantedAuthority> getAuthorities() {
|
||||
return null;
|
||||
if (authorities != null) {
|
||||
return authorities;
|
||||
}
|
||||
|
||||
authorities = user.getOperations().stream().map(operation -> new SimpleGrantedAuthority(operation.getCode())).collect(Collectors.toList());
|
||||
return authorities;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
|
||||
Reference in New Issue
Block a user