Changeset - 22bc0f7cc2b4
[Not reviewed]
default
0 1 0
Mads Kiilerich - 7 years ago 2018-12-26 22:55:06
mads@kiilerich.com
auth: drop UserCreationError handling for AuthUser.from_cookie

Simplify the code a bit, and take an unnecessary concern out of sight.

Users with cookie auth must already exist in the system, and they will thus
never be created on the fly when using a cookie for authentication.

If completely weird things should happen anyway, it would probably be better to
get a clear stack trace.
1 file changed with 1 insertions and 9 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/base.py
Show inline comments
 
@@ -447,21 +447,13 @@ class BaseController(TGController):
 
        # Authenticate by session cookie
 
        # In ancient login sessions, 'authuser' may not be a dict.
 
        # In that case, the user will have to log in again.
 
        # v0.3 and earlier included an 'is_authenticated' key; if present,
 
        # this must be True.
 
        if isinstance(session_authuser, dict) and session_authuser.get('is_authenticated', True):
 
            try:
 
                return AuthUser.from_cookie(session_authuser)
 
            except UserCreationError as e:
 
                # container auth or other auth functions that create users on
 
                # the fly can throw UserCreationError to signal issues with
 
                # user creation. Explanation should be provided in the
 
                # exception object.
 
                from kallithea.lib import helpers as h
 
                h.flash(e, 'error', logf=log.error)
 
            return AuthUser.from_cookie(session_authuser)
 

	
 
        # Authenticate by auth_container plugin (if enabled)
 
        if any(
 
            plugin.is_container_auth
 
            for plugin in auth_modules.get_auth_plugins()
 
        ):
0 comments (0 inline, 0 general)