Fix date formats
continuous-integration/drone/push Build is passing Details

pull/15/head
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():
if app.config["ENABLE_SWAGGER"] == "1":
swag = swagger(app)
swag["info"]["version"] = "1.2.6"
swag["info"]["version"] = "1.2.7"
swag["info"]["title"] = "SelfPrivacy API"
swag["info"]["description"] = "SelfPrivacy API"
swag["securityDefinitions"] = {

View File

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

View File

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

View File

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