🐛 oauth 封装,直接获取用户名为空问题修复

This commit is contained in:
lengleng committed 2019-03-11 15:18:13 +08:00
1 parent 910739c090
commit e0d9cce2fd
6 files changed
+9 -35

No files matched your search

@@ -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);
}
@@ -34,7 +34,7 @@ import java.util.Objects;
/**
* @author lengleng
* <p>
* fallBack 代理处理
* fallback 代理处理
*/
@Slf4j
@AllArgsConstructor