fix
This commit is contained in:
+5
-3
@@ -36,10 +36,12 @@ public class GlobalExceptionHandler {
|
||||
|
||||
@ExceptionHandler(UnauthorizedException.class)
|
||||
public ResponseEntity<ErrorDTO> unauthorized(UnauthorizedException e, HttpServletRequest req) {
|
||||
String scheme = req.getRequestURI().equals("/api/v1/auth/sessions")
|
||||
? "Basic" : "Bearer";
|
||||
boolean isLogin = "/api/v1/auth/sessions".equals(req.getRequestURI());
|
||||
String challenge = isLogin
|
||||
? "Basic realm=\"messenger\", charset=\"UTF-8\""
|
||||
: "Bearer realm=\"messenger\"";
|
||||
return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
|
||||
.header("WWW-Authenticate", scheme + " realm=\"messenger\"")
|
||||
.header("WWW-Authenticate", challenge)
|
||||
.body(errors.error(ErrorErrorDTO.CodeEnum.UNAUTHORIZED, e.getMessage(), req));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user