mirror of
https://github.com/bec-project/bec_atlas.git
synced 2025-07-14 07:01:48 +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:
|
try:
|
||||||
payload = decode_token(token)
|
payload = decode_token(token)
|
||||||
groups = payload.get("groups")
|
|
||||||
email = payload.get("email")
|
email = payload.get("email")
|
||||||
if not groups or not email:
|
if not email:
|
||||||
raise credentials_exception
|
raise credentials_exception
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
raise credentials_exception from exc
|
raise credentials_exception from exc
|
||||||
|
@ -60,7 +60,7 @@ class UserRouter(BaseRouter):
|
|||||||
user = self._get_user(user_login)
|
user = self._get_user(user_login)
|
||||||
if user is None:
|
if user is None:
|
||||||
raise HTTPException(status_code=401, detail="User not found or password is incorrect")
|
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)
|
response.set_cookie(key="access_token", value=token, httponly=True, secure=self.use_ssl)
|
||||||
return token
|
return token
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ function handle_request(handler: HttpHandler, req: HttpRequest<any>) {
|
|||||||
error: (err: any) => {
|
error: (err: any) => {
|
||||||
if (err instanceof HttpErrorResponse) {
|
if (err instanceof HttpErrorResponse) {
|
||||||
console.log('err.status', err);
|
console.log('err.status', err);
|
||||||
if (err.status === 401) {
|
if (err.status === 401 && !err.url?.includes('login')) {
|
||||||
logout();
|
logout();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ export class AuthService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setSession(authResult: string) {
|
setSession(authResult: string) {
|
||||||
console.log(authResult);
|
|
||||||
// it would be good to get an expiration date for the token...
|
// it would be good to get an expiration date for the token...
|
||||||
localStorage.setItem('id_session', this.getRandomId());
|
localStorage.setItem('id_session', this.getRandomId());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user