From 5cd752a096398661b4d9928c6993ce98f31c377a Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Tue, 25 Aug 2020 22:33:30 +0200 Subject: [PATCH] Sidewards compatibility with pluginify. Some cleanup --- geruecht/model/user.py | 2 +- geruecht/routes.py | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/geruecht/model/user.py b/geruecht/model/user.py index 543859c..6003432 100644 --- a/geruecht/model/user.py +++ b/geruecht/model/user.py @@ -227,7 +227,7 @@ class User(): "dn": self.dn, "firstname": self.firstname, "lastname": self.lastname, - "group": self.group, + "groups": self.group, "username": self.uid, "locked": self.locked, "autoLock": self.autoLock, diff --git a/geruecht/routes.py b/geruecht/routes.py index 810b141..1eb8232 100644 --- a/geruecht/routes.py +++ b/geruecht/routes.py @@ -216,16 +216,16 @@ def _getUsers(**kwargs): return jsonify({"error": str(err)}), 500 -@app.route("/getLifeTime", methods=['GET']) +@app.route("/getLifetime", methods=['GET']) @login_required(groups=[MONEY, GASTRO, VORSTAND, EXTERN, USER], bar=True) -def _getLifeTime(**kwargs): +def _getLifetime(**kwargs): try: debug.info("get lifetime of accesstoken") if 'accToken' in kwargs: accToken = kwargs['accToken'] debug.debug("accessToken is {{ {} }}".format(accToken)) retVal = {"value": accToken.lifetime, - "group": accToken.user.toJSON()['group'], + "groups": accToken.user.toJSON()['groups'], "lock_bar": accToken.lock_bar} debug.info( "return get lifetime from accesstoken {{ {} }}".format(retVal)) @@ -235,11 +235,11 @@ def _getLifeTime(**kwargs): return jsonify({"error": str(err)}), 500 -@app.route("/saveLifeTime", methods=['POST']) +@app.route("/setLifetime", methods=['POST']) @login_required(groups=[MONEY, GASTRO, VORSTAND, EXTERN, USER], bar=True) -def _saveLifeTime(**kwargs): +def _setLifetime(**kwargs): try: - debug.info("save lifetime for accessToken") + debug.info("set lifetime for accessToken") if 'accToken' in kwargs: accToken = kwargs['accToken'] debug.debug("accessToken is {{ {} }}".format(accToken)) @@ -253,7 +253,7 @@ def _saveLifeTime(**kwargs): accToken = accesTokenController.updateAccessToken(accToken) accToken = accesTokenController.validateAccessToken(accToken.token, [USER, EXTERN]) retVal = {"value": accToken.lifetime, - "group": accToken.user.toJSON()['group']} + "groups": accToken.user.toJSON()['groups']} debug.info( "return save lifetime for accessToken {{ {} }}".format(retVal)) return jsonify(retVal) @@ -320,7 +320,6 @@ def _login(): debug.info("validate accesstoken") dic = accesTokenController.validateAccessToken( token, [USER, EXTERN]).user.toJSON() - dic["token"] = token dic["accessToken"] = token debug.info("User {{ {} }} success login.".format(username)) debug.info("return login {{ {} }}".format(dic))