Commit cef4ec8d by xieshaohua

secuirty获取user信息修改

parent bf714367
......@@ -70,11 +70,22 @@ public class UserInfoUtils {
//author:zhangkb time:2020-1-6 desc:添加标签用到获取session属性接口
public static String getUserName() {
return SecurityContextHolder.getContext().getAuthentication().getName().split(":")[0];
// return SecurityContextHolder.getContext().getAuthentication().getName().split(":")[0];
Object obj = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
System.out.println(obj.toString());
UserDetails userDetails = (UserDetails) obj;
String userNameWithIdAttached = userDetails.getUsername();
return userNameWithIdAttached.split(":")[0];
}
public static String getUserId() {
return SecurityContextHolder.getContext().getAuthentication().getName().split(":")[1];
Object obj = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
System.out.println(obj.toString());
UserDetails userDetails = (UserDetails) obj;
String userNameWithIdAttached = userDetails.getUsername();
return userNameWithIdAttached.split(":")[1];
// return SecurityContextHolder.getContext().getAuthentication().getName().split(":")[1];
}
//获取当前用户所属机构(id:name)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment