Use user id instead of email
This commit is contained in:
parent
9c3edfeb8c
commit
879423f7c7
@ -41,12 +41,17 @@ def get_email_from_token_data():
|
|||||||
|
|
||||||
if token is not None:
|
if token is not None:
|
||||||
if ':' in token: # Maybe bot token, check if token valid and return username after ":" then
|
if ':' in token: # Maybe bot token, check if token valid and return username after ":" then
|
||||||
email = token.split(":")[1]
|
telegram_user_id = token.split(":")[1]
|
||||||
token = token.split(":")[0]
|
token = token.split(":")[0]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if jwt.decode(token, os.getenv('SECRET_KEY'), algorithms=["HS256"])['email'] == os.getenv("BOT_EMAIL"):
|
if jwt.decode(token, os.getenv('SECRET_KEY'), algorithms=["HS256"])['email'] == os.getenv("BOT_EMAIL"):
|
||||||
return email
|
res = db.session.query(User).filter_by(telegram_user_id=telegram_user_id).first()
|
||||||
|
|
||||||
|
if res is not None:
|
||||||
|
return res.as_dict()['email']
|
||||||
|
else:
|
||||||
|
return None
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
except jwt.PyJWTError:
|
except jwt.PyJWTError:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user