mirror of
https://github.com/bec-project/bec_atlas.git
synced 2025-07-13 22:51:49 +02:00
fix(auth): removed groups from token
This commit is contained in:
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -27,7 +27,7 @@ function handle_request(handler: HttpHandler, req: HttpRequest<any>) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
Reference in New Issue
Block a user