Exemple #1
0
 def logout(self):
     if 'user' not in session:
         return redirect('/')
     else:
         session.pop('user')
         session.save()
         return redirect('/')
Exemple #2
0
def authenticated_user(reload=False):
    """
    Returns reference to AuthenticatedUser which is stored in session.
    If it's not in session method will add it and save session, then return object.
    """

    AUTHENTICATED_USER = "******"

    # Create authenticated user if it doesn't exist
    if request.environ.has_key('REMOTE_USER'):
        if reload or not session.has_key(AUTHENTICATED_USER) \
            or session[AUTHENTICATED_USER] == None \
            or session[AUTHENTICATED_USER].username != request.environ['REMOTE_USER']:
            model = request.environ['sqlalchemy.model']
            db = request.environ['sqlalchemy.session']

            try:
                authenticated_user = db.query(model.AuthenticatedUser).filter_by(username=request.environ['REMOTE_USER']).one()
            except:
                authenticated_user = model.AuthenticatedUser(
                    username = request.environ['REMOTE_USER'], email = request.environ['REMOTE_USER'])
                db.save(authenticated_user)
                db.commit()
                log.info(_("Created an %s" % (str(authenticated_user))))
            db.expunge(authenticated_user)
            session[AUTHENTICATED_USER] = authenticated_user
            session.save()
    
        return session[AUTHENTICATED_USER]

    if session.has_key(AUTHENTICATED_USER):
        session.pop(AUTHENTICATED_USER, None)
        session.save()

    return None
Exemple #3
0
 def logout(self):
     if "user" not in session:
         return redirect("/")
     else:
         session.pop("user")
         session.save()
         return redirect("/")
 def index(self):
     c.user_name = session.pop('user_name', '')
     c.user_url = session.pop('user_url', '')
     c.user_phone = session.pop('user_phone', '')
     c.user_email = session.pop('user_email', '')
     c.capcha_error = session.pop('capcha_error', '')
     session.save()
     return render('/register_user.mako.html')
 def import_metadata(self, **kwargs):
     if request.method == 'POST':
         redirect_url = self._import_metadata(request.params)
         h.redirect_to(redirect_url)
     else:
         c.group_id = request.params.get('group')
         c.error_summary = session.pop('error_summary', None)
         c.errors = session.pop('errors', None)
         c.result = session.pop('result', None)
         return render('package/import_metadata.html')
 def import_metadata(self, **kwargs):
     if request.method == 'POST':
         redirect_url = self._import_metadata(request.params)
         redirect(redirect_url)
     else:
         c.group_id = request.params.get('group')
         c.error_summary = session.pop('error_summary', None)
         c.errors = session.pop('errors', None)
         c.result = session.pop('result', None)
         return render('package/import_metadata.html')
Exemple #7
0
 def logout(self):
     if 'user' not in session:
         session['flash'] = 'Not logged in'
         session.save()
         return redirect('/')
     else:
         session.pop('user')
         session.save()
         session['flash'] = 'Successfully logged out'
         session.save()
         return redirect('/')
    def _process_contact(self):

        # Validate secure_form's (CSRF protection) token

        if not (request.params.get(secure_form.token_key) == secure_form.authentication_token()):
            abort (403, detail=u'Not permitted (possible CSRF attack)')

        # If cancelled, dont do anything

        if request.params.get('op') != 'Submit':
            session.pop('contactform.errors', None)
            session.pop('contactform.values', None)
            return url(controller='contactform', action='nevermind')

        # Validate form fields ...

        schema = ContactForm()
        try:
            fields = schema.to_python(dict(request.params))
            session.pop('contactform.errors', None)
            session.pop('contactform.values', None)
            self._save_contact(fields, schema)
            return url(controller='contactform', action='thanks')
        except formencode.Invalid, ex:
            session.update({
                'contactform.errors': ex.error_dict,
                'contactform.values': ex.value,
            })
            return url(controller='contactform', action='contact')
Exemple #9
0
    def logged_in(self):
        # we need to set the language via a redirect
        lang = session.pop("lang", None)
        session.save()
        came_from = request.params.get("came_from", "")

        # 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(_("%s is now logged in") % user_dict["display_name"])
            if came_from:
                return h.redirect_to(str(came_from))
            return self.me()
        else:
            err = _("Login failed. Bad username or password.")
            if g.openid_enabled:
                err += _(" (Or if using OpenID, it hasn't been associated " "with a user account.)")
            if h.asbool(config.get("ckan.legacy_templates", "false")):
                h.flash_error(err)
                h.redirect_to(locale=lang, controller="user", action="login", came_from=came_from)
            else:
                return self.login(error=err)
Exemple #10
0
 def pop_messages(self):
     from pylons import session
     messages = session.pop(self.session_key, [])
     # only save session if it has changed
     if messages:
         session.save()
     return [Message(*m) for m in messages]
Exemple #11
0
    def do_signin(self):
        path_before_login = session.pop("path_before_login", self.default_path)
        
        g = self._py_object.app_globals
        
        # disable api check in *.ini config
        if g.check_api:
            api = eveapi.EVEAPIConnection()

            auth = api.auth(userID=c.api_userid, apiKey=c.api_key)
            
            def check_character(name):
                try:
                    result = auth.account.Characters()
                except eveapi.Error, e:
                    c.errors.add(e.args[0])
                    return None

                for char in result.characters:
                    if char.name == name:
                        return char
                return None
            
            def get_corp(char):
                try:
                    result = auth.corp.CorporationSheet(characterID=char.characterID)
                except eveapi.Error, e:
                    c.errors.add(e.args[0])
                    return None
                
                return result
Exemple #12
0
 def pop_message(self):
     message = session.pop("flash", None)
     session['flash'] = None
     session.save()
     if not message:
         return None
     return message
Exemple #13
0
    def logged_in(self):
        # we need to set the language via a redirect
        lang = session.pop('lang', None)
        session.save()

        # we need to set the language explicitly here or the flash
        # messages will not be translated.
        ckan.lib.i18n.set_lang(lang)

        if c.user:
            context = {'model': model, 'user': c.user}

            data_dict = {'id': c.user}

            user_dict = get_action('user_show')(context, data_dict)

            h.flash_success(
                _("%s is now logged in") % user_dict['display_name'])
            return self.me(locale=lang)
        else:
            err = _('Login failed. Bad username or password.')
            if g.openid_enabled:
                err += _(' (Or if using OpenID, it hasn\'t been associated '
                         'with a user account.)')
            h.flash_error(err)
            h.redirect_to(locale=lang, controller='user', action='login')
Exemple #14
0
 def pop_message(self):
     message = session.pop("flash", None)
     session['flash'] = None
     session.save()
     if not message:
         return None
     return message
Exemple #15
0
    def logged_in(self):
        # we need to set the language via a redirect
        lang = session.pop('lang', None)
        session.save()

        # we need to set the language explicitly here or the flash
        # messages will not be translated.
        ckan.lib.i18n.set_lang(lang)

        if c.user:
            context = {'model': model,
                       'user': c.user}

            data_dict = {'id': c.user}

            user_dict = get_action('user_show')(context, data_dict)

            h.flash_success(_("%s is now logged in") %
                            user_dict['display_name'])
            return self.me(locale=lang)
        else:
            err = _('Login failed. Bad username or password.')
            if g.openid_enabled:
                err += _(' (Or if using OpenID, it hasn\'t been associated '
                         'with a user account.)')
            h.flash_error(err)
            h.redirect_to(locale=lang, controller='user', action='login')
    def logged_in(self):
        # we need to set the language via a redirect
        lang = session.pop('lang', None)
        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:
            is_new = False
            is_sysadmin = new_authz.is_sysadmin(c.user)

            # Retrieve information about the current user
            context = {'model': model, 'session': model.Session,
                   'user': c.user or c.author,
                   'schema': schema.user_new_form_schema()}
            data_dict = {'id': c.user}

            user_dict = get_action('user_show')(context, data_dict)

            # This check is not needed (or correct) for sys admins
            if not is_sysadmin:

                # Get all organizations and all groups the user belongs to
                orgs_q = model.Session.query(model.Group) \
                    .filter(model.Group.is_organization == True) \
                    .filter(model.Group.state == 'active')
                q = model.Session.query(model.Member) \
                    .filter(model.Member.table_name == 'user') \
                    .filter(model.Member.table_id == user_dict['id'])

                group_ids = []
                for row in q.all():
                    group_ids.append(row.group_id)

                if not group_ids:
                    is_new = True
                else:
                    orgs_q = orgs_q.filter(model.Group.id.in_(group_ids))

                    orgs_list = model_dictize.group_list_dictize(orgs_q.all(), context)

                    if len(orgs_list) == 0:
                        is_new = True

            h.flash_success(_("<p><strong>Note</strong></p>"
                "<p>%s is now logged in</p>") %
                user_dict['display_name'], allow_html=True)

            if is_new:
                return h.redirect_to(controller='ckanext.canada.controller:CanadaController',
                                         action='view_new_user', locale=lang)
            else:
                return h.redirect_to(controller='package',
                    action='search', locale=lang)
        else:
            h.flash_error(_('Login failed. Bad username or password.'))
            return h.redirect_to(controller='user',
                action='login', locale=lang)
Exemple #17
0
    def logged_in(self):
        # we need to set the language via a redirect
        lang = session.pop('lang', None)
        session.save()
        came_from = request.params.get('came_from', '')

        # 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(_("%s is now logged in") %
                            user_dict['display_name'])
            if came_from:
                return h.redirect_to(str(came_from))
            return self.me()
        else:
            err = _('Login failed. Bad username or password.')
            if g.openid_enabled:
                err += _(' (Or if using OpenID, it hasn\'t been associated '
                         'with a user account.)')
            if h.asbool(config.get('ckan.legacy_templates', 'false')):
                h.flash_error(err)
                h.redirect_to(locale=lang, controller='user',
                              action='login', came_from=came_from)
            else:
                return self.login(error=err)
Exemple #18
0
    def login(self, error=None):
        lang = session.pop('lang', None)
        if lang:
            session.save()
            return h.redirect_to(locale=str(lang), controller='user',
                                 action='login')
        if 'error' in request.params:
            h.flash_error(request.params['error'])

        if request.environ['SCRIPT_NAME'] and g.openid_enabled:
            # #1662 restriction
            log.warn('Cannot mount CKAN at a URL and login with OpenID.')
            g.openid_enabled = False

        if not c.user:
            came_from = request.params.get('came_from', '')
            c.login_handler = h.url_for(
                self._get_repoze_handler('login_handler_path'),
                came_from=came_from)
            if error:
                vars = {'error_summary': {'': error}}
            else:
                vars = {}
            return render('user/login.html', extra_vars=vars)
        else:
            return render('user/logout_first.html')
Exemple #19
0
    def pop_messages(self):
        """Return all accumulated messages and delete them from the session.

        The return value is a list of ``Message`` objects.
        """
        from pylons import session
        messages = session.pop(self.session_key, [])
        session.save()
        return [Message(**m) for m in messages]
Exemple #20
0
    def _finish_signup(self):
        c.person = h.signed_in_person()
        self.finish_edit(c.person)

        redirect_location = session.pop('redirect_to', None)
        if redirect_location:
            redirect_to(str(redirect_location))
        else:
            redirect_to('home')
Exemple #21
0
 def _process_login(self):
     user = self.form_result['user']
     user.process_login()        
     success_flash('You have logged into PylonsHQ')
     if session.get('redirect'):
         redir_url = session.pop('redirect')
         session.save()
         redirect(url(redir_url))
     redirect(url('home'))
    def pop_messages(self):
        """Return all accumulated messages and delete them from the session.

        The return value is a list of ``Message`` objects.
        """
        from pylons import session
        messages = session.pop(self.session_key, [])
        session.save()
        return [_Message(*m) for m in messages]
Exemple #23
0
    def signin(self):

        role_error = session.pop('role_error', None)
        if role_error:
            h.flash(role_error)
        elif h.signed_in_person():
            h.flash("You're already logged in")
            redirect_to('home')

        return render('/person/signin.mako')
Exemple #24
0
def getFlash(toRender=True):
	session = _get_session()
	if(toRender):
		session['flashRendered'] = True
	flash = session.get("flash",False)
	if not toRender and session.get('flashRendered',False):
		flash = session.pop("flash",False)
	session.save()
	return flash
	pass
 def signout(self):
     domain = request.params.get('domain')
     username = request.params.get('username')
     userid = request.params.get('userid')
     if domain and username or userid:
         try:
             keys = [k for k in session.get('account_keys', '').split(',') if k]
             rem_keys = keys[:]
             for k in keys:
                 acct = session[k]
                 if acct['domain']==domain and \
                    (not username or acct['username']==username) and \
                    (not userid or acct['userid']==userid):
                     session.pop(k)
                     rem_keys.remove(k)
             session['account_keys'] = ','.join(rem_keys)
         except:
             log.exception('failed to signout from domain %s', domain)
             session.clear()
     else:
         session.clear()
     session.save()
    def login(self):
        lang = session.pop('lang', None)
        if lang:
            session.save()
            return h.redirect_to(locale=str(lang),
                                 controller='user',
                                 action='login')
        if 'error' in request.params:
            h.flash_error(request.params['error'])

        g.openid_enabled = False

        if not c.user:
            #removed

            if c.removed and not c.is_allowed_to_switch:
                #removed

                try:
                    found = False
                    results = get_action('group_list')(context, data_dict)
                    #removed
                except NotFound:
                    abort(404, _('Group not found'))
                except NotAuthorized:
                    abort(401, _('Unauthorized to read group %s') % id)

                if not found:
                    msg = ""
                    if c.fullname:
                        msg += u"Name: %s\r\n" % c.fullname
                    if c.email:
                        msg += u"Email: %s\r\n" % c.email
                else:
                    #removed
                    msg = ""
                    if c.fullname:
                        msg += u"Name: %s\r\n" % c.fullname
                    if c.email:
                        msg += u"Email: %s\r\n" % c.email
                    h.redirect_to(locale=lang,
                                  controller='user',
                                  action='logged_in')

            return render('user/login.html')
        else:
            h.redirect_to(
                controller=
                'ckanext.dgvat_por.controllers.dgvat_cockpit:DgvatCockpitController',
                action='search')
Exemple #27
0
 def _process_openid_associate(self):
     openid_url = session.get('openid_identity')
     user = self.form_result['user']
     if user.openids:
         user.openids.append(openid_url)
     else:
         user.openids = [openid_url]
     user.process_login()
     success_flash('You have associated your OpenID to your account, and signed in')
     if session.get('redirect'):
         redir_url = session.pop('redirect')
         session.save()
         redirect(url(redir_url))
     redirect(url('home'))
Exemple #28
0
 def signout(self):
     domain = request.params.get('domain')
     username = request.params.get('username')
     userid = request.params.get('userid')
     if domain and username or userid:
         try:
             keys = [k for k in session.get('account_keys', '').split(',') if k]
             for k in keys:
                 session.pop(k)
             _and = [Account.domain==domain]
             if username:
                 _and.append(Account.username==username)
             if userid:
                 _and.append(Account.userid==userid)
             accts = Session.query(Account).filter(Account.key.in_(keys)).filter(not_(and_(*_and))).all()
             session['account_keys'] = ','.join([a.key for a in accts])
             for a in accts:
                 session[a.key] = a.to_dict()
         except:
             session.clear()
     else:
         session.clear()
     session.save()
Exemple #29
0
    def _signin(self):

        # Tell authkit we authenticated them
        request.environ['paste.auth_tkt.set_user'](c.email)

        h.flash('You have signed in')

        redirect_location = session.pop('redirect_to', None)
        if redirect_location:
            redirect_to(str(redirect_location))

        if lca_info['conference_status'] == 'open':
            redirect_to(controller='registration', action='status')

        redirect_to('home')
Exemple #30
0
    def _signin(self):

        # Tell authkit we authenticated them
        request.environ['paste.auth_tkt.set_user'](c.email)

        h.flash('You have signed in')

        redirect_location = session.pop('redirect_to', None)
        if redirect_location:
            redirect_to(str(redirect_location))

        if lca_info['conference_status'] == 'open':
            redirect_to(controller='registration', action='status')

        redirect_to('home')
Exemple #31
0
 def signout(self):
     domain = request.params.get('domain')
     username = request.params.get('username')
     userid = request.params.get('userid')
     if domain and username or userid:
         try:
             keys = [
                 k for k in session.get('account_keys', '').split(',') if k
             ]
             rem_keys = keys[:]
             for k in keys:
                 acct = session[k]
                 if acct['domain']==domain and \
                    (not username or acct['username']==username) and \
                    (not userid or acct['userid']==userid):
                     session.pop(k)
                     rem_keys.remove(k)
             session['account_keys'] = ','.join(rem_keys)
         except:
             log.exception('failed to signout from domain %s', domain)
             session.clear()
     else:
         session.clear()
     session.save()
Exemple #32
0
 def signout(self):
     domain = request.params.get("domain")
     username = request.params.get("username")
     userid = request.params.get("userid")
     if domain and username or userid:
         try:
             keys = [k for k in session.get("account_keys", "").split(",") if k]
             rem_keys = keys[:]
             for k in keys:
                 acct = session[k]
                 if (
                     acct["domain"] == domain
                     and (not username or acct["username"] == username)
                     and (not userid or acct["userid"] == userid)
                 ):
                     session.pop(k)
                     rem_keys.remove(k)
             session["account_keys"] = ",".join(rem_keys)
         except:
             log.exception("failed to signout from domain %s", domain)
             session.clear()
     else:
         session.clear()
     session.save()
Exemple #33
0
    def finish_login(self, email):
        # Tell authkit we authenticated them
        request.environ['paste.auth_tkt.set_user'](email)

        h.check_for_incomplete_profile(c.person)

        h.flash('You have signed in')

        redirect_location = session.pop('redirect_to', None)
        if redirect_location:
            redirect_to(str(redirect_location))

        if lca_info['conference_status'] == 'open':
            redirect_to(controller='registration', action='status')

        redirect_to('home')
Exemple #34
0
    def finish_login(self, email):
        # Tell authkit we authenticated them
        request.environ['paste.auth_tkt.set_user'](email)

        h.check_for_incomplete_profile(c.person)

        h.flash('You have signed in')

        redirect_location = session.pop('redirect_to', None)
        if redirect_location:
            redirect_to(str(redirect_location))

        if lca_info['conference_status'] == 'open':
            redirect_to(controller='registration', action='status')

        redirect_to('home')
Exemple #35
0
    def login(self):
        lang = session.pop('lang', None)
        if lang:
            session.save()
            return h.redirect_to(locale=str(lang), controller='user', action='login')
        if 'error' in request.params:
            h.flash_error(request.params['error'])

        if request.environ['SCRIPT_NAME'] and g.openid_enabled:
            # #1662 restriction
            log.warn('Cannot mount CKAN at a URL and login with OpenID.')
            g.openid_enabled = False

        if not c.user:
            return render('user/login.html')
        else:
            return render('user/logout_first.html')
Exemple #36
0
    def login(self):
        lang = session.pop('lang', None)
        if lang:
            session.save()
            return h.redirect_to(locale=str(lang), controller='user', action='login')
        if 'error' in request.params:
            h.flash_error(request.params['error'])

        if request.environ['SCRIPT_NAME'] and g.openid_enabled:
            # #1662 restriction
            log.warn('Cannot mount CKAN at a URL and login with OpenID.')
            g.openid_enabled = False

        if not c.user:
            return render('user/login.html')
        else:
            return render('user/logout_first.html')
    def logged_in(self):
        # we need to set the language via a redirect
        lang = session.pop('lang', None)
        session.save()
        if c.user:
            context = {'model': model,
                       'user': c.user}

            data_dict = {'id':c.user}

            user_dict = get_action('user_show')(context,data_dict)

            #h.flash_success(_("%s is now logged in") % user_dict['display_name'])
            h.redirect_to(controller='ckanext.dgvat_por.controllers.dgvat_cockpit:DgvatCockpitController', action='search')
        else:
            err = _('Login failed. Bad username or password.')
            h.flash_error(err)
            h.redirect_to(locale=lang, controller='user', action='login')
Exemple #38
0
    def logged_in(self):
        # we need to set the language via a redirect
        lang = session.pop('lang', None)
        session.save()
        if c.user:
            context = {'model': model,
                       'user': c.user}

            data_dict = {'id':c.user}

            user_dict = get_action('user_show')(context,data_dict)

            h.flash_success(_("%s is now logged in") % user_dict['display_name'])
            return self.me(locale=lang)
        else:
            h.flash_error(_('Login failed. Bad username or password.' + \
                          ' (Or if using OpenID, it hasn\'t been associated with a user account.)'))
            h.redirect_to(locale=lang, controller='user', action='login')
Exemple #39
0
    def logged_in(self):
        # we need to set the language via a redirect
        lang = session.pop('lang', None)
        session.save()
        if c.user:
            context = {'model': model,
                       'user': c.user}

            data_dict = {'id':c.user}

            user_dict = get_action('user_show')(context,data_dict)

            h.flash_success(_("%s is now logged in") % user_dict['display_name'])
            return self.me(locale=lang)
        else:
            h.flash_error(_('Login failed. Bad username or password.' + \
                          ' (Or if using OpenID, it hasn\'t been associated with a user account.)'))
            h.redirect_to(locale=lang, controller='user', action='login')
    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:
            h.flash_error(_('Login failed. Bad username or password.'))
            return h.redirect_to(
                controller='user',
                action='login', locale=lang
            )
    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:
            h.flash_error(_('Login failed. Bad username or password.'))
            return h.redirect_to(
                controller='user',
                action='login', locale=lang
            )
    def logged_in(self):
        # we need to set the language via a redirect
        lang = session.pop('lang', None)
        session.save()
        if c.user:
            context = {'model': model, 'user': c.user}

            data_dict = {'id': c.user}

            user_dict = get_action('user_show')(context, data_dict)

            #h.flash_success(_("%s is now logged in") % user_dict['display_name'])
            h.redirect_to(
                controller=
                'ckanext.dgvat_por.controllers.dgvat_cockpit:DgvatCockpitController',
                action='search')
        else:
            err = _('Login failed. Bad username or password.')
            h.flash_error(err)
            h.redirect_to(locale=lang, controller='user', action='login')
Exemple #43
0
    def logged_in(self):
        """Minor rewrite to redirect the user to the own profile page instead of
        the dashboard.
        """
        # we need to set the language via a redirect
        lang = session.pop('lang', None)
        session.save()
        came_from = request.params.get('came_from', '')
        if came_from and not came_from.isspace():
            came_from = came_from\
                        .replace('\n', ' ')\
                        .replace('\r', '')


        # we need to set the language explicitly here or the flash
        # messages will not be translated.
        ckan.lib.i18n.set_lang(lang)

        if h.url_is_local(came_from):
            return h.redirect_to(unquote(str(came_from)))

        if c.user:
            context = {'model': model,
                       'user': c.user}

            data_dict = {'id': c.user}

            user_dict = get_action('user_show')(context, data_dict)

            #h.flash_success(_("%s is now logged in") %
            #                user_dict['display_name'])
            return h.redirect_to(controller='user', action='read', id=c.userobj.name)
        else:
            err = _('Login failed. Bad username or password.')
            if asbool(config.get('ckan.legacy_templates', 'false')):
                h.flash_error(err)
                h.redirect_to(controller='user',
                              action='login', came_from=came_from)
            else:
                return self.login(error=err)
Exemple #44
0
 def pop_messages(self):
     messages = session.pop(self.session_key, [])
     # only save session if it has changed
     if messages:
         session.save()
     return [Message(*m) for m in messages]
Exemple #45
0
 def style(self):
     return session.pop("flash.style", 'notice')
Exemple #46
0
 def pop_messages(self):
     from pylons import session
     messages = session.pop(self.session_key, [])
     session.save()
     return [Message(*m) for m in messages]
Exemple #47
0
 def pop_messages(self):
     from pylons import session
     messages = session.pop( self.key, [] )
     session.save()
     return messages