Skip to content

Commit

Permalink
feat: 未登录情况返回
Browse files Browse the repository at this point in the history
  • Loading branch information
lichong-a committed Sep 16, 2024
1 parent 2ef14d2 commit 8632e2b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.funcode.portal.server.common.core.base.http.response.ResponseResult;
import org.funcode.portal.server.common.core.security.domain.vo.signup.SignUpRequest;
import org.funcode.portal.server.common.core.security.service.IAuthenticationService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

/**
* @author 李冲
Expand All @@ -29,9 +29,16 @@
public class AuthController {
private final IAuthenticationService authenticationService;

@PostMapping("/signup")
@PostMapping("signup")
@Operation(summary = "注册")
public ResponseResult<String> signup(@RequestBody @Valid SignUpRequest request) {
return authenticationService.signup(request);
}

@Operation(summary = "未认证返回")
@GetMapping("unauthorized")
public void unauthorized(HttpServletResponse response) {
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
response.setStatus(HttpStatus.UNAUTHORIZED.value());
}
}
4 changes: 2 additions & 2 deletions starter/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ application:
# 注销成功跳转地址,默认为"/login?logout"
logout-success-url:
# 登录页地址,默认:/login
login-page:
login-page: http://127.0.0.1:8080/api/v1/auth/unauthorized
token:
# 签名密钥
signing-key: portalserver8fas8hage9SHVfsd847GD8475fd8880ejf
Expand All @@ -28,7 +28,7 @@ application:
- '*'
cors-allowed-methods:
- '*'
cors-allow-credentials: true
cors-allow-credentials: false
cos:
secret-id: ${COS_SECRET_ID}
secret-key: ${COS_SECRET_KEY}
Expand Down

0 comments on commit 8632e2b

Please sign in to comment.