feat: show error message when oauth callback error (#34)

* feat: show error message when oauth callback error

* fix: checkstyle
This commit is contained in:
vran
2022-03-05 13:09:03 +08:00
committed by GitHub
parent 842643ea4f
commit f2a7019ec4
5 changed files with 26 additions and 11 deletions

View File

@@ -1,7 +1,7 @@
package com.databasir.api.config.security;
import com.databasir.core.domain.app.exception.DatabasirAuthenticationException;
import com.databasir.common.JsonData;
import com.databasir.core.domain.app.exception.DatabasirAuthenticationException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
@@ -42,7 +42,7 @@ public class DatabasirAuthenticationFailureHandler implements AuthenticationFail
response.getOutputStream().write(jsonString.getBytes(StandardCharsets.UTF_8));
} else if (exception instanceof DatabasirAuthenticationException) {
DatabasirAuthenticationException bizException = (DatabasirAuthenticationException) exception;
JsonData<Void> data = JsonData.error("-1", bizException.getMessage());
JsonData<Void> data = JsonData.error(bizException.getErrCode(), bizException.getErrMessage());
String jsonString = objectMapper.writeValueAsString(data);
response.setStatus(HttpStatus.OK.value());
response.getOutputStream().write(jsonString.getBytes(StandardCharsets.UTF_8));