SUPPORT-8643: Fix
This commit is contained in:
parent
e790011d1d
commit
9373e897c4
3 changed files with 25 additions and 29 deletions
|
|
@ -40,9 +40,8 @@ public class EsiaController {
|
|||
|
||||
@GetMapping(value = "/esia/auth")
|
||||
public void esiaAuth(@RequestParam(value = "code", required = false) String code,
|
||||
@RequestParam(value = "error", required = false) String error, HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
esiaAuthService.authEsiaTokensByCode(code, error, request, response);
|
||||
esiaAuthService.authEsiaTokensByCode(code, response);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/esia/refresh")
|
||||
|
|
|
|||
|
|
@ -152,11 +152,7 @@ public class EsiaAuthService {
|
|||
return uriBuilder.toString();
|
||||
}
|
||||
|
||||
public void authEsiaTokensByCode(String esiaAuthCode, String error,
|
||||
HttpServletRequest request, HttpServletResponse response) {
|
||||
if (error != null && !error.equals("null")) {
|
||||
throw new EsiaException(error);
|
||||
}
|
||||
public void authEsiaTokensByCode(String esiaAuthCode, HttpServletResponse response) {
|
||||
String esiaAccessTokenStr = null;
|
||||
String prnOid = null;
|
||||
Long expiresIn = null;
|
||||
|
|
|
|||
|
|
@ -30,25 +30,9 @@ export abstract class AuthGuard implements CanActivate {
|
|||
if (isAccess) {
|
||||
return true;
|
||||
}
|
||||
if (code || error) {
|
||||
const params = new HttpParams().set('code', code).set('error', error);
|
||||
this.httpClient.get("esia/auth",
|
||||
{
|
||||
params: params, responseType: 'text', observe: 'response', headers: {
|
||||
"Error-intercept-skip": "true"
|
||||
}
|
||||
})
|
||||
.toPromise()
|
||||
.then(
|
||||
(response) => {
|
||||
window.open(url.origin + url.pathname, "_self");
|
||||
})
|
||||
.catch((reason) => {
|
||||
let errorMessage = reason.error.messages != null
|
||||
? reason.error.messages
|
||||
: reason.error.replaceAll('\\', '');
|
||||
if (error) {
|
||||
errorMessage = 'Произошла неизвестная ошибка. Обратитесь к системному администратору';
|
||||
let errorMessage =
|
||||
'Произошла неизвестная ошибка. Обратитесь к системному администратору';
|
||||
let errorCode = this.extractCode(errorDescription);
|
||||
if (errorCode) {
|
||||
errorMessage = EsiaErrorDetail.getDescription(errorCode);
|
||||
|
|
@ -57,10 +41,27 @@ export abstract class AuthGuard implements CanActivate {
|
|||
this.messageService.error(errorMessage);
|
||||
console.error(consoleError);
|
||||
}
|
||||
else {
|
||||
this.messageService.error(errorMessage);
|
||||
console.error(reason);
|
||||
if (code) {
|
||||
const params = new HttpParams().set('code', code);
|
||||
this.httpClient.get("esia/auth",
|
||||
{
|
||||
params: params,
|
||||
responseType: 'text',
|
||||
observe: 'response',
|
||||
headers: {
|
||||
"Error-intercept-skip": "true"
|
||||
}
|
||||
})
|
||||
.toPromise()
|
||||
.then(
|
||||
() => {
|
||||
window.open(url.origin + url.pathname, "_self");
|
||||
})
|
||||
.catch(reason => {
|
||||
const json = JSON.parse(reason.error);
|
||||
json.messages.forEach((errorMessage) => {
|
||||
this.messageService.error(errorMessage, json);
|
||||
});
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue