Example #1
0
    def web_login(self, redirect=None, **kw):    
        ensure_db()

        if request.httprequest.method == 'GET' and redirect and request.session.uid:
            return http.redirect_with_hash(redirect)

        if not request.uid:
            request.uid = openerp.SUPERUSER_ID

        values = request.params.copy()
        if not redirect:
            redirect = '/web?' + request.httprequest.query_string
        values['redirect'] = redirect

        try:
            values['databases'] = http.db_list()
        except openerp.exceptions.AccessDenied:
            values['databases'] = None

        if request.httprequest.method == 'POST':
            old_uid = request.uid
            uid = request.session.authenticate(request.session.db, request.params['login'], request.params['password'])
            if uid is not False:
                return http.redirect_with_hash(redirect)
            request.uid = old_uid
            values['error'] = _("Please check your email address and password")
        if request.env.ref('web.login', False):
            return request.render('web.login', values)
        else:
            # probably not an odoo compatible database
            error = 'Unable to login on database %s' % request.session.db
            return werkzeug.utils.redirect('/web/database/selector?error=%s' % error, 303)
Example #2
0
 def web_login(self, redirect=None, *args, **kw):
     r = super(Website, self).web_login(redirect=redirect, *args, **kw)
     if request.params['login_success'] and not redirect:
         if request.registry['res.users'].has_group(request.cr, request.uid, 'base.group_user'):
             redirect = '/web?' + request.httprequest.query_string
         else:
             redirect = '/'
         return http.redirect_with_hash(redirect)
     return r
Example #3
0
 def web_login(self, redirect=None, *args, **kw):
     r = super(Website, self).web_login(redirect=redirect, *args, **kw)
     if request.params["login_success"] and not redirect:
         if request.registry["res.users"].has_group(request.cr, request.uid, "base.group_user"):
             redirect = "/web?" + request.httprequest.query_string
         else:
             redirect = "/"
         return http.redirect_with_hash(redirect)
     return r