def _authenticate_user(self, username, email, fullname, is_superuser=False): user = m.User.get(username) if not is_superuser or is_superuser == 'False': is_superuser = False else: is_superuser = True if user is None: data_dict = { 'name': unicode(username), 'email': email, 'fullname': fullname, 'password': uuid4().hex } try: user_obj = l.get_action('user_create')({ 'ignore_auth': True }, data_dict) except Exception as e: log.error(e) abort(500, str(e)) if is_superuser: try: user_obj.update({'sysadmin': True}) l.get_action('user_update')({ 'ignore_auth': True }, user_obj) except Exception as e: log.error(e) set_repoze_user(user_obj['name']) delete_user_entry(user_obj['name']) return user_obj['name'] else: if user.name != username or user.email != email or user.fullname != fullname or user.sysadmin != is_superuser: try: user_obj = { 'id': username, 'email': email, 'fullname': fullname, 'sysadmin': is_superuser } l.get_action('user_update')({ 'ignore_auth': True }, user_obj) except Exception as e: log.error(e) abort(500, str(e)) set_repoze_user(username) delete_user_entry(username) return username
def logout(self): delete_user_entry(t.c.user) if t.asbool(config.get('ckanext.cas.single_sign_out')): cas_logout_url = self.CAS_LOGOUT_URL + '?service=' + self.CAS_APP_URL + '/cas/logout' redirect(cas_logout_url) # TODO: Refactor into helper url = h.url_for(controller='user', action='logged_out_page', __ckan_no_root=True) h.redirect_to(getattr(t.request.environ['repoze.who.plugins']['friendlyform'], 'logout_handler_path') + '?came_from=' + url)
def _authenticate_user(self, username, email, fullname, is_superuser=False): user = m.User.get(username) if is_superuser and is_superuser == ADMIN: is_superuser = True elif is_superuser and is_superuser == MEMBER: is_superuser = False else: abort( 403, 'Solo se pueden autenticar los usuarios pertenecientes al equipo del ISTAC' ) if user is None: data_dict = { 'name': unicode(username), 'email': email, 'fullname': fullname, 'password': uuid4().hex } try: user_obj = l.get_action('user_create')({ 'ignore_auth': True }, data_dict) except Exception as e: log.error(e) abort(500, str(e)) if is_superuser: try: user_obj.update({'sysadmin': True}) l.get_action('user_update')({ 'ignore_auth': True }, user_obj) except Exception as e: log.error(e) set_repoze_user(user_obj['name']) delete_user_entry(user_obj['name']) return user_obj['name'] else: if user.name != username or user.email != email or user.fullname != fullname or user.sysadmin != is_superuser: try: user_obj = { 'id': username, 'email': email, 'fullname': fullname, 'sysadmin': is_superuser } l.get_action('user_update')({ 'ignore_auth': True }, user_obj) except Exception as e: log.error(e) abort(500, str(e)) set_repoze_user(username) delete_user_entry(username) return username