🐛 oauth 封装,直接获取用户名为空问题修复
This commit is contained in:
1 parent
910739c090
commit
e0d9cce2fd
6 files changed
+9
-35
No files matched your search
-26
@@ -62,37 +62,11 @@ public class SecurityUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用名
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getUsername() {
|
||||
Object principal = getAuthentication().getPrincipal();
|
||||
if (principal instanceof String) {
|
||||
return principal.toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public String getClientId() {
|
||||
Authentication authentication = getAuthentication();
|
||||
if (authentication instanceof OAuth2Authentication) {
|
||||
OAuth2Authentication auth2Authentication = (OAuth2Authentication) authentication;
|
||||
return auth2Authentication.getOAuth2Request().getClientId();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户
|
||||
*/
|
||||
public PigxUser getUser() {
|
||||
Authentication authentication = getAuthentication();
|
||||
if (authentication == null) {
|
||||
return null;
|
||||
}
|
||||
return getUser(authentication);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ import java.util.Objects;
|
||||
/**
|
||||
* @author lengleng
|
||||
* <p>
|
||||
* fallBack 代理处理
|
||||
* fallback 代理处理
|
||||
*/
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
|
||||
Reference in new issue
Block a user