simplify the token

Keep it in a list, for forward compatibillity
This commit is contained in:
Glandos 2021-08-01 22:46:04 +02:00
parent e25d5dbfd2
commit 6c0d0e22b0

View file

@ -350,12 +350,12 @@ class Project(db.Model):
serializer = URLSafeTimedSerializer( serializer = URLSafeTimedSerializer(
current_app.config["SECRET_KEY"], salt=token_type current_app.config["SECRET_KEY"], salt=token_type
) )
token = serializer.dumps({"project_id": self.id}) token = serializer.dumps([self.id])
else: else:
serializer = URLSafeSerializer( serializer = URLSafeSerializer(
current_app.config["SECRET_KEY"] + self.password, salt=token_type current_app.config["SECRET_KEY"] + self.password, salt=token_type
) )
token = serializer.dumps({"project_id": self.id}) token = serializer.dumps([self.id])
return token return token
@ -390,7 +390,7 @@ class Project(db.Model):
except BadSignature: except BadSignature:
return None return None
data_project = data.get("project_id") data_project = data[0] if isinstance(data, list) else None
return ( return (
data_project if project_id is None or data_project == project_id else None data_project if project_id is None or data_project == project_id else None
) )