Skip to content

Commit

Permalink
chore: handle session and return detailed error
Browse files Browse the repository at this point in the history
  • Loading branch information
ful1e5 committed Nov 21, 2023
1 parent 7ca7029 commit 2111f21
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
6 changes: 4 additions & 2 deletions core/utils/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ def wrapper(*args, **kwargs):
k = session_keys["build"]
id: str = session.get(k, None)

invalid_session = jsonify({"status": 401, "error": ["Invalid Session"]})
unauth = jsonify({"status": 401, "error": ["Unauthorized."]})

if id:
Expand All @@ -24,7 +23,10 @@ def wrapper(*args, **kwargs):
return auth[0], auth[1]
else:
if auth.id != id:
return invalid_session, 401
return (
jsonify({"status": 401, "error": [f"Invalid Session {id}"]}),
401,
)
else:
g.auth = auth
return f(*args, **kwargs)
Expand Down
13 changes: 6 additions & 7 deletions src/components/DownloadButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,12 @@ export const DownloadButton: React.FC<Props> = (props) => {
};
}, []);

// TODO: Clear Session for cleaning build files in temporary directory of core-api function
// useEffect(() => {
// if (lock === false) {
// const api = new CoreApi();
// api.deleteSession();
// }
// }, [lock, props.lock, props.disabled, props.auth]); // eslint-disable-line react-hooks/exhaustive-deps
useEffect(() => {
if (lock === false) {
const api = new CoreApi();
api.deleteSession();
}
}, [lock, props.disabled, props.auth]); // eslint-disable-line react-hooks/exhaustive-deps

const busy = loading || props.disabled;

Expand Down
1 change: 1 addition & 0 deletions src/utils/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class CoreApi {
});

const data = await res.json();
this.jwt = undefined;
return data as DeleteSessionResponse;
}

Expand Down

0 comments on commit 2111f21

Please sign in to comment.