mirror of
https://github.com/PowerJob/PowerJob.git
synced 2025-07-17 00:00:04 +08:00
style: [auth] optimize code
This commit is contained in:
parent
fb15227fe2
commit
48d6b1b85e
@ -43,7 +43,7 @@ public class PowerJobAuthInterceptor implements HandlerInterceptor {
|
||||
}
|
||||
|
||||
// 尝试直接解析登陆
|
||||
final Optional<PowerJobUser> loginUserOpt = powerJobAuthService.parse(request);
|
||||
final Optional<PowerJobUser> loginUserOpt = powerJobAuthService.ifLogin(request);
|
||||
|
||||
// 未登录前先使用302重定向到登录页面
|
||||
if (!loginUserOpt.isPresent()) {
|
||||
|
@ -28,7 +28,7 @@ public interface PowerJobAuthService {
|
||||
* @param httpServletRequest httpServletRequest
|
||||
* @return PowerJob 用户
|
||||
*/
|
||||
Optional<PowerJobUser> parse(HttpServletRequest httpServletRequest);
|
||||
Optional<PowerJobUser> ifLogin(HttpServletRequest httpServletRequest);
|
||||
|
||||
/**
|
||||
* 判断用户是否有访问权限
|
||||
|
@ -88,7 +88,7 @@ public class PowerJobLoginServiceImpl implements PowerJobAuthService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<PowerJobUser> parse(HttpServletRequest httpServletRequest) {
|
||||
public Optional<PowerJobUser> ifLogin(HttpServletRequest httpServletRequest) {
|
||||
|
||||
final Optional<Long> userIdOpt = parseUserId(httpServletRequest);
|
||||
return userIdOpt.flatMap(aLong -> userInfoRepository.findById(aLong).map(userInfoDO -> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user