Skip to content

Commit

Permalink
fixed save metadata api (not sending user info)
Browse files Browse the repository at this point in the history
  • Loading branch information
soaibsafi committed Jun 5, 2024
1 parent 89abb91 commit 30c5129
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion backend/routes/playground.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ def run_spectra():
@routes.route('/api/save-with-meta', methods=['POST'])
@limiter.limit("2/second", error_message="You've already made a request recently.")
def save_with_metadata():
# Get user information
user_id = session.get('user_id')
current_time = datetime.now(pytz.utc)
data = request.get_json()
check_type = data['check']
code = data['code']
Expand Down Expand Up @@ -218,7 +221,8 @@ def save_with_metadata():
check_type=check_type,
permalink=permalink,
meta=metadata,
code_id=code_id
code_id=code_id,
user_id=user_id
)
db.session.add(new_data)
db.session.commit()
Expand All @@ -228,6 +232,7 @@ def save_with_metadata():
response = make_response(jsonify({'permalink': "There is a problem. Please try after some time."}), 500)
return response

session['last_request_time'] = current_time
response = make_response(jsonify({'check':check_type,'permalink': permalink}), 200)
return response

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/api/playgroundApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export async function saveCodeWithMetadata(code, check, parent, metadata) {
let url = `${API_URL}/save-with-meta`;
let meta = `{cmd: ${metadata}}`;
try {
const response = await axios.post(url, { code, check, parent, meta });
const response = await axiosAuth.post(url, { code, check, parent, meta });
if (response.status === 200) {
return response;
}
Expand Down

0 comments on commit 30c5129

Please sign in to comment.