Mercurial > kallithea
changeset 7693:05dc948c9788
auth: use other and better checks than is_authenticated
These are the two only uses of is_authenticated, and we are fine without it.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Sun, 07 Apr 2019 23:35:23 +0200 |
parents | 0e3e0864f210 |
children | 1e83cda87899 |
files | kallithea/controllers/login.py kallithea/lib/auth.py |
diffstat | 2 files changed, 8 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/controllers/login.py Thu Jan 03 01:16:36 2019 +0100 +++ b/kallithea/controllers/login.py Sun Apr 07 23:35:23 2019 +0200 @@ -107,8 +107,9 @@ raise HTTPFound(location=c.came_from) else: # redirect if already logged in - if request.authuser.is_authenticated: + if not request.authuser.is_anonymous: raise HTTPFound(location=c.came_from) + # continue to show login to default user return render('/login.html')
--- a/kallithea/lib/auth.py Thu Jan 03 01:16:36 2019 +0100 +++ b/kallithea/lib/auth.py Sun Apr 07 23:35:23 2019 +0200 @@ -701,16 +701,16 @@ raise HTTPForbidden() # regular user authentication - if user.is_authenticated: - log.info('user %s authenticated with regular auth @ %s', user, loc) - return func(*fargs, **fkwargs) - elif user.is_default_user: + if user.is_default_user: if self.allow_default_user: log.info('default user @ %s', loc) return func(*fargs, **fkwargs) log.info('default user is not accepted here @ %s', loc) - else: - log.warning('user %s NOT authenticated with regular auth @ %s', user, loc) + elif user.is_anonymous: # default user is disabled and no proper authentication + log.warning('user is anonymous and NOT authenticated with regular auth @ %s', loc) + else: # regular authentication + log.info('user %s authenticated with regular auth @ %s', user, loc) + return func(*fargs, **fkwargs) raise _redirect_to_login()