change env file name

This commit is contained in:
Cayo Puigdefabregas 2021-03-02 21:27:14 +01:00
parent 8f3c9c33cb
commit 7e541f13a1
4 changed files with 16 additions and 4 deletions

View File

@ -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

View File

@ -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',

View File

@ -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')