Skip to content
Snippets Groups Projects
Commit 688b85d9 authored by sveseli's avatar sveseli
Browse files

fix unauthorized string error in login controller

parent aff629ba
No related branches found
No related tags found
No related merge requests found
...@@ -170,19 +170,20 @@ class LoginController(DmController): ...@@ -170,19 +170,20 @@ class LoginController(DmController):
raise DmHttpError(dmHttpStatus.DM_HTTP_UNAUTHORIZED, 'User Not Authorized', InvalidSession(errorMsg)) raise DmHttpError(dmHttpStatus.DM_HTTP_UNAUTHORIZED, 'User Not Authorized', InvalidSession(errorMsg))
username = sessionInfo.get(LoginController.SESSION_USERNAME_KEY) username = sessionInfo.get(LoginController.SESSION_USERNAME_KEY)
if not username:
errorMsg = 'Invalid session id: %s (no username supplied).' % sessionId
logger.debug(errorMsg)
raise DmHttpError(dmHttpStatus.DM_HTTP_UNAUTHORIZED, 'User Not Authorized', InvalidSession(errorMsg))
cherrypy.session[LoginController.SESSION_ROLE_KEY] = sessionInfo[LoginController.SESSION_ROLE_KEY] cherrypy.session[LoginController.SESSION_ROLE_KEY] = sessionInfo[LoginController.SESSION_ROLE_KEY]
logger.debug('Session id %s is valid (username: %s)' % (sessionId, username)) logger.debug('Session id %s is valid (username: %s)' % (sessionId, username))
if username: cherrypy.request.login = username
cherrypy.request.login = username for condition in conditions:
for condition in conditions: # A condition is just a callable that returns true or false
# A condition is just a callable that returns true or false if not condition():
if not condition(): logger.debug('Authorization check %s() failed for username %s' % (condition.func_name, username))
logger.debug('Authorization check %s() failed for username %s' % (condition.func_name, username)) errorMsg = 'Authorization check %s() failed for user %s.' % (condition.func_name, username)
errorMsg = 'Authorization check %s() failed for user %s.' % (condition.func_name, username) raise DmHttpError(dmHttpStatus.DM_HTTP_UNAUTHORIZED, 'User Not Authorized', AuthorizationError(errorMsg))
raise DmHttpError(dmHttpStatus.DM_HTTP_UNAUTHORIZED, 'User Not Authorized', AuthorizationError(errorMsg))
else:
logger.debug('Username is not supplied')
raise DmHttpError(dmHttpStatus.DM_HTTP_UNAUTHORIZED, 'User Not Authorized', ex)
@cherrypy.expose @cherrypy.expose
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment