diff --git a/backend/bec_atlas/authentication.py b/backend/bec_atlas/authentication.py index 8f59f51..288ed5d 100644 --- a/backend/bec_atlas/authentication.py +++ b/backend/bec_atlas/authentication.py @@ -91,9 +91,8 @@ def get_current_user_sync(token: str) -> UserInfo: ) try: payload = decode_token(token) - groups = payload.get("groups") email = payload.get("email") - if not groups or not email: + if not email: raise credentials_exception except Exception as exc: raise credentials_exception from exc diff --git a/backend/bec_atlas/router/user_router.py b/backend/bec_atlas/router/user_router.py index 79883ff..ecb71c1 100644 --- a/backend/bec_atlas/router/user_router.py +++ b/backend/bec_atlas/router/user_router.py @@ -60,7 +60,7 @@ class UserRouter(BaseRouter): user = self._get_user(user_login) if user is None: raise HTTPException(status_code=401, detail="User not found or password is incorrect") - token = create_access_token(data={"groups": list(user.groups), "email": user.email}) + token = create_access_token(data={"email": user.email}) response.set_cookie(key="access_token", value=token, httponly=True, secure=self.use_ssl) return token diff --git a/frontend/bec_atlas/src/app/core/auth.interceptor.ts b/frontend/bec_atlas/src/app/core/auth.interceptor.ts index 5989e7d..61a7e40 100644 --- a/frontend/bec_atlas/src/app/core/auth.interceptor.ts +++ b/frontend/bec_atlas/src/app/core/auth.interceptor.ts @@ -27,7 +27,7 @@ function handle_request(handler: HttpHandler, req: HttpRequest) { error: (err: any) => { if (err instanceof HttpErrorResponse) { console.log('err.status', err); - if (err.status === 401) { + if (err.status === 401 && !err.url?.includes('login')) { logout(); } } diff --git a/frontend/bec_atlas/src/app/core/auth.service.ts b/frontend/bec_atlas/src/app/core/auth.service.ts index 5a212f2..6a9dbbb 100644 --- a/frontend/bec_atlas/src/app/core/auth.service.ts +++ b/frontend/bec_atlas/src/app/core/auth.service.ts @@ -21,7 +21,6 @@ export class AuthService { } setSession(authResult: string) { - console.log(authResult); // it would be good to get an expiration date for the token... localStorage.setItem('id_session', this.getRandomId()); }