fix cookie name

This commit is contained in:
Eduard Tihomirov 2024-09-25 13:51:45 +03:00
parent 64195a3728
commit f114a70949
4 changed files with 16 additions and 9 deletions

View file

@ -223,9 +223,9 @@ public class EsiaAuthService {
.setAuthentication(
new UsernamePasswordAuthenticationToken(esiaAccessToken.getSbj_id(), null));
Cookie isAuth = new Cookie("is_auth", "true");
isAuth.setPath(cookiePath);
Cookie isAuth = new Cookie("webbpm.ervu-lkrp-fl", "true");
isAuth.setMaxAge(tokenResponse.getExpires_in().intValue());
isAuth.setPath("/");
response.addCookie(isAuth);
return true;
}
@ -323,9 +323,9 @@ public class EsiaAuthService {
.setAuthentication(
new UsernamePasswordAuthenticationToken(esiaAccessToken.getSbj_id(), null));
Cookie isAuth = new Cookie("is_auth", "true");
Cookie isAuth = new Cookie("webbpm.ervu-lkrp-fl", "true");
isAuth.setMaxAge(tokenResponse.getExpires_in().intValue());
isAuth.setPath(cookiePath);
isAuth.setPath("/");
response.addCookie(isAuth);
}
catch (Exception e) {
@ -370,9 +370,16 @@ public class EsiaAuthService {
Cookie[] cookies = request.getCookies();
if (cookies != null)
for (Cookie cookie : cookies) {
if (cookie.getName().equals("auth_token") || cookie.getName().equals("refresh_token")
|| cookie.getName().equals("access_token") || cookie.getName().equals("is_auth")) {
if (cookie.getName().equals("webbpm.ervu-lkrp-fl")) {
cookie.setValue("");
cookie.setPath("/");
cookie.setMaxAge(0);
response.addCookie(cookie);
}
else if (cookie.getName().equals("auth_token") || cookie.getName().equals("refresh_token")
|| cookie.getName().equals("access_token")) {
cookie.setValue("");
cookie.setPath(cookie.getPath());
cookie.setMaxAge(0);
response.addCookie(cookie);
}

View file

@ -15,7 +15,7 @@ export class PersonDataRoot extends Behavior{
let personScripts: PersonData[] = this.container.getScriptsInThisAndChildren(PersonData);
let httpClient = this.injector.get(HttpClient);
let cookieService = this.injector.get(CookieService);
if (cookieService.get("is_auth")) {
if (cookieService.get("webbpm.ervu-lkrp-fl")) {
httpClient.get<PersonDataModel>("esia/person")
.toPromise()
.then(personModel => {

View file

@ -38,6 +38,6 @@ export class LogOutComponent implements OnInit{
}
public getIsAuth(): boolean {
return this.cookieService.get("is_auth") != null;
return this.cookieService.get("webbpm.ervu-lkrp-fl") != null;
}
}

View file

@ -56,6 +56,6 @@ export abstract class AuthGuard implements CanActivate {
};
public getIsAuth(): string {
return this.cookieService.get('is_auth');
return this.cookieService.get('webbpm.ervu-lkrp-fl');
}
}