|
|
@@ -30,6 +30,7 @@ import me.zhengjie.application.admin.service.dto.RoleSmallDto;
|
|
|
import me.zhengjie.application.admin.service.dto.UserDto;
|
|
|
import me.zhengjie.application.admin.service.dto.UserQueryCriteria;
|
|
|
import me.zhengjie.base.AppBaseResponse;
|
|
|
+import me.zhengjie.base.ResultCode;
|
|
|
import me.zhengjie.base.util.ApplicationContextUtil;
|
|
|
import me.zhengjie.base.util.BeanCopyUtils;
|
|
|
import me.zhengjie.base.util.FileUploadUtil;
|
|
|
@@ -48,6 +49,9 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.security.authentication.AnonymousAuthenticationToken;
|
|
|
+import org.springframework.security.core.Authentication;
|
|
|
+import org.springframework.security.core.context.SecurityContextHolder;
|
|
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
@@ -306,4 +310,17 @@ public class UserController {
|
|
|
public AppBaseResponse getAuthStatus(){
|
|
|
return userService.getAuthStatus();
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 校验登录状态
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AnonymousPostMapping("/checkAuth")
|
|
|
+ public AppBaseResponse<?> checkAuth(){
|
|
|
+ Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
|
|
+ if (authentication == null || authentication instanceof AnonymousAuthenticationToken) {
|
|
|
+ return AppBaseResponse.error(ResultCode.PERMISSION_TOKEN_INVALID);
|
|
|
+ }
|
|
|
+ return AppBaseResponse.success();
|
|
|
+ }
|
|
|
+
|
|
|
}
|