Skip to content

Commit

Permalink
Merge pull request #17 from anuj0456/deployment-setup
Browse files Browse the repository at this point in the history
iat removed from jwt du to timezone mismatch
  • Loading branch information
anuj0456 authored Jan 18, 2025
2 parents f54e678 + 425002b commit 8b370ce
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions utils/auth_utility.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import logging

import jwt
import configparser
from functools import wraps
Expand All @@ -12,7 +14,6 @@
def create_token(user_id):
payload = {
'exp': datetime.now() + timedelta(days=1),
'iat': datetime.now(),
'sub': user_id
}

Expand Down Expand Up @@ -42,13 +43,14 @@ def decorated(*args, **kwargs):
try:
# Decode token
data = jwt.decode(token, JWT_SECRET_KEY, algorithms=["HS256"])
current_user = data['user']
except:
current_user = data['sub']
except Exception as e:
logging.info("Token error" + str(e))
return jsonify({
'message': 'Token is invalid',
'status': 'error'
}), 401

return f(current_user, *args, **kwargs)
return f(*args, **kwargs)

return decorated

0 comments on commit 8b370ce

Please sign in to comment.