[root] redirect user to homepage when trying to access the login page

To see the login page, one of theses conditions must be met:
 - no user logged
 - a LoginToken is present in the URL and the corresponding object
   exists
This commit is contained in:
Benjamin Dauvergne 2011-01-28 13:46:36 +00:00
parent 1ac95186ed
commit 8c65f982d0
1 changed files with 5 additions and 0 deletions

View File

@ -393,6 +393,11 @@ class RootDirectory(Directory):
return self.login(allow_direct = False)
def login [html] (self, allow_direct = True): # only works with PasswordAccount for now
request = get_request()
# Already logged no login token (not a ForceAuthn login)
if request.user is not None and (not get_field('LoginToken')
or login_token.LoginToken.get(get_field('LoginToken'), ignore_errors=True) is None):
return misc.redirect_home()
if allow_direct and get_cfg('idp', {}).get('direct_proxy'):
for klp, lp in get_cfg('providers', {}).items():
if lp['role'] == lasso.PROVIDER_ROLE_SP: