Fix date formats

This commit is contained in:
Inex Code 2022-05-31 11:46:58 +03:00
parent 401dff23fb
commit c30e062210
4 changed files with 13 additions and 7 deletions

View File

@ -68,7 +68,7 @@ def create_app(test_config=None):
def spec(): def spec():
if app.config["ENABLE_SWAGGER"] == "1": if app.config["ENABLE_SWAGGER"] == "1":
swag = swagger(app) swag = swagger(app)
swag["info"]["version"] = "1.2.6" swag["info"]["version"] = "1.2.7"
swag["info"]["title"] = "SelfPrivacy API" swag["info"]["title"] = "SelfPrivacy API"
swag["info"]["description"] = "SelfPrivacy API" swag["info"]["description"] = "SelfPrivacy API"
swag["securityDefinitions"] = { swag["securityDefinitions"] = {

View File

@ -23,4 +23,4 @@ class ApiVersion(Resource):
401: 401:
description: Unauthorized description: Unauthorized
""" """
return {"version": "1.2.6"} return {"version": "1.2.7"}

View File

@ -120,7 +120,7 @@ def create_token(name):
{ {
"token": token, "token": token,
"name": name, "name": name,
"date": str(datetime.now()), "date": str(datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%fZ")),
} }
) )
return token return token
@ -282,9 +282,15 @@ def _get_new_device_auth_token():
new_device = tokens["new_device"] new_device = tokens["new_device"]
if "expiration" not in new_device: if "expiration" not in new_device:
return None return None
if datetime.now() > datetime.strptime( if new_device["expiration"].endswith("Z"):
new_device["expiration"], "%Y-%m-%d %H:%M:%S.%f" expiration = datetime.strptime(
): new_device["expiration"], "%Y-%m-%dT%H:%M:%S.%fZ"
)
else:
expiration = datetime.strptime(
new_device["expiration"], "%Y-%m-%d %H:%M:%S.%f"
)
if datetime.now() > expiration:
return None return None
return new_device["token"] return new_device["token"]

View File

@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup( setup(
name="selfprivacy_api", name="selfprivacy_api",
version="1.2.6", version="1.2.7",
packages=find_packages(), packages=find_packages(),
scripts=[ scripts=[
"selfprivacy_api/app.py", "selfprivacy_api/app.py",