diff --git a/ereuse_devicehub/resources/documents/documents.py b/ereuse_devicehub/resources/documents/documents.py index 947ac85e..46e1cbf3 100644 --- a/ereuse_devicehub/resources/documents/documents.py +++ b/ereuse_devicehub/resources/documents/documents.py @@ -304,9 +304,9 @@ class WbConfDocumentView(DeviceView): } data['erase'] = False if wbtype == 'usodyrate' else True - env = flask.render_template('documents/env', **data) + env = flask.render_template('documents/wbConfiguration.ini', **data) output = make_response(env) - output.headers['Content-Disposition'] = 'attachment; filename=.env' + output.headers['Content-Disposition'] = 'attachment; filename=Configuration.ini' output.headers['Content-type'] = 'text/plain' return output diff --git a/ereuse_devicehub/resources/documents/templates/documents/env b/ereuse_devicehub/resources/documents/templates/documents/wbConfiguration.ini similarity index 100% rename from ereuse_devicehub/resources/documents/templates/documents/env rename to ereuse_devicehub/resources/documents/templates/documents/wbConfiguration.ini diff --git a/ereuse_devicehub/resources/user/__init__.py b/ereuse_devicehub/resources/user/__init__.py index ec9eed78..d4bf8354 100644 --- a/ereuse_devicehub/resources/user/__init__.py +++ b/ereuse_devicehub/resources/user/__init__.py @@ -7,7 +7,7 @@ from teal.resource import Converters, Resource from ereuse_devicehub.db import db from ereuse_devicehub.resources.user import schemas from ereuse_devicehub.resources.user.models import User -from ereuse_devicehub.resources.user.views import UserView, login +from ereuse_devicehub.resources.user.views import UserView, login, logout class UserDef(Resource): @@ -23,6 +23,8 @@ class UserDef(Resource): super().__init__(app, import_name, static_folder, static_url_path, template_folder, url_prefix, subdomain, url_defaults, root_path, cli_commands) self.add_url_rule('/login/', view_func=login, methods={'POST'}) + logout1 = app.auth.requires_auth(logout) + self.add_url_rule('/logout/', view_func=logout1, methods={'GET'}) @argument('email') @option('-i', '--inventory', diff --git a/ereuse_devicehub/resources/user/views.py b/ereuse_devicehub/resources/user/views.py index 7053eea7..e6376f3c 100644 --- a/ereuse_devicehub/resources/user/views.py +++ b/ereuse_devicehub/resources/user/views.py @@ -1,8 +1,10 @@ -from uuid import UUID +from uuid import UUID, uuid4 from flask import g, request +from flask.json import jsonify from teal.resource import View +from ereuse_devicehub.db import db from ereuse_devicehub.resources.user.exceptions import WrongCredentials from ereuse_devicehub.resources.user.models import User from ereuse_devicehub.resources.user.schemas import User as UserS @@ -24,3 +26,11 @@ def login(): return schema_with_token.jsonify(user) else: raise WrongCredentials() + + +def logout(): + # We use custom schema as we only want to parse a subset of user + g.user.token = uuid4() + db.session.add(g.user) + db.session.commit() + return jsonify('Ok')