Sidewards compatibility with pluginify. Some cleanup

This commit is contained in:
Ferdinand Thiessen 2020-08-25 22:33:30 +02:00
parent 07a0d266a6
commit 5cd752a096
2 changed files with 8 additions and 9 deletions

View File

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

View File

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