def auth_successful(self, username):
# save ref before calling UserSession login() as it
# may regenerate the session
- ref = cherrypy.config.get('base.mount', "") + '/'
- if 'referral' in cherrypy.session:
- ref = cherrypy.session['referral']
+ session = UserSession()
+ ref = session.get_data('login', 'Return')
+ if not ref:
+ ref = cherrypy.config.get('base.mount', "") + '/'
- UserSession().login(username)
+ session.login(username)
raise cherrypy.HTTPRedirect(ref)
def auth_failed(self):
- # Just make sure we destroy the session
- UserSession().logout(None)
-
+ # try with next module
if self.next_login:
return self.redirect_to_path(self.next_login.path)
- ref = cherrypy.config.get('base.mount', "") + '/unauthorized'
+ # return to the caller if any
+ session = UserSession()
+ ref = session.get_data('login', 'Return')
+
+ # otherwise destroy session and return error
+ if not ref:
+ ref = cherrypy.config.get('base.mount', "") + '/unauthorized'
+ # Just make sure we destroy the session
+ session.logout(None)
+
raise cherrypy.HTTPRedirect(ref)
self._site[FACILITY] = loader.get_plugin_data()
plugins = self._site[FACILITY]
+ available = plugins['available'].keys()
+ self._debug('Available login managers: %s' % str(available))
+
prev_obj = None
- for item in plugins['available']:
- self._log('Login plugin available: %s' % item)
- if item not in plugins['whitelist']:
+ for item in plugins['whitelist']:
+ self._debug('Login plugin in whitelist: %s' % item)
+ if item not in plugins['available']:
continue
- self._log('Login plugin enabled: %s' % item)
+ self._debug('Login plugin enabled: %s' % item)
plugins['enabled'].append(item)
obj = plugins['available'][item]
if prev_obj:
obj.set_config(plugins['config'][item])
self.__dict__[item] = obj.get_tree(self._site)
- def _log(self, fact):
- if cherrypy.config.get('debug', False):
- cherrypy.log(fact)
-
def root(self, *args, **kwargs):
if self.first_login:
raise cherrypy.HTTPRedirect('%s/login/%s' %