def register(self, data=None, errors=None, error_summary=None): '''GET to display a form for registering a new user. or POST the form data to actually do the user registration. The bulk of this code is pulled directly from ckan/controlllers/user.py ''' context = {'model': model, 'session': model.Session, 'user': c.user or c.author, 'schema': schema.user_new_form_schema(), 'save': 'save' in request.params} try: check_access('user_create', context) except NotAuthorized: abort(401, _('Unauthorized to create a user')) if context['save'] and not data: uc = UserController() return uc._save_new(context) if c.user and not data: # #1799 Don't offer the registration form if already logged in return render('user/logout_first.html') data = data or {} errors = errors or {} error_summary = error_summary or {} vars = {'data': data, 'errors': errors, 'error_summary': error_summary} c.is_sysadmin = new_authz.is_sysadmin(c.user) c.form = render('user/new_user_form.html', extra_vars=vars) return render('user/new.html')
def __before__(self, action, **env): UserController.__before__(self, action, **env) check1 = request.params.get("ext_field-filters") ps = request.params.get("ext_field-filters-select") check2 = request.params.get("ext_field-actions") ac = request.params.get("ext_field-actions-select") if check1: c.process_state = ps if check2: c.action_multi = ac
def logged_in(self): controller = UserController() if not c.user: # a number of failed login attempts greater than 10 # indicates that the locked user is associated with the current request qgovUser = Session.query(QGOVUser).filter(QGOVUser.login_attempts > 10).first() if qgovUser: qgovUser.login_attempts = 10 Session.commit() return controller.login("account-locked") return controller.logged_in()
def logged_in(self): controller = UserController() if not c.user: # a number of failed login attempts greater than 10 # indicates that the locked user is associated with the current request seedUser = Session.query(SEEDUser).filter( SEEDUser.login_attempts > 10).first() if seedUser: seedUser.login_attempts = 10 Session.commit() return controller.login('account-locked') return controller.logged_in()
def logged_in(self): #log.debug("insde-------------------") controller = UserController() if not c.user: # a number of failed login attempts greater than 10 # indicates that the locked user is associated with the current request seedUser = Session.query(SEEDUser).filter( SEEDUser.login_attempts > 5).first() if seedUser: seedUser.login_attempts = 5 Session.commit() return controller.login( 'Login Failed: Bad username or password') return controller.logged_in()
def __before__(self, action, **env): UserController.__before__(self, action, **env) try: context = { 'model': model, 'user': c.user, 'auth_user_obj': c.userobj } check_access('site_read', context) except NotAuthorized: if c.action not in ( 'login', 'request_reset', 'perform_reset', ): abort(403, _('Not authorized to see this page'))
def logged_in(self): # we need to set the language via a redirect # Lang is not being retrieved properly by the Babel i18n lib in # this redirect, so using this clunky workaround for now. lang = session.pop('lang', None) if lang is None: came_from = request.params.get('came_from', '') if came_from.startswith('/fr'): lang = 'fr' else: lang = 'en' session.save() # we need to set the language explicitly here or the flash # messages will not be translated. i18n.set_lang(lang) if c.user: context = None data_dict = {'id': c.user} user_dict = get_action('user_show')(context, data_dict) h.flash_success( _('<strong>Note</strong><br>{0} is now logged in').format( user_dict['display_name']), allow_html=True) notice_no_access() return h.redirect_to( controller='ckanext.canada.controller:CanadaController', action='home', locale=lang) else: error_summary = _('Login failed. Bad username or password.') # replace redirect with a direct call to login controller # pass error_summary to controller as error # so that it can be captured for GA events in our overridden templates return UserController.login(self, error_summary)
def __before__(self, action, **env): log.fatal("Before: %s" % __name__) UserController.__before__(self, action, **env) context = '' self._setup_template_variables(context)
def __before__(self, action, **env): UserController.__before__(self, action, **env) c.display_private_only = True
def _save_new(self, context): context['schema'] = schema.user_new_form_schema() return UserController._save_new(self, context)