[IMP] web,website: portal users should be redirected to the frontend on login (and regulars users to the backend) on login
This commit is contained in:
@@ -487,7 +487,7 @@ class Home(http.Controller):
|
||||
@http.route('/web/login', type='http', auth="none")
|
||||
def web_login(self, redirect=None, **kw):
|
||||
ensure_db()
|
||||
|
||||
request.params['login_success'] = False
|
||||
if request.httprequest.method == 'GET' and redirect and request.session.uid:
|
||||
return http.redirect_with_hash(redirect)
|
||||
|
||||
@@ -495,10 +495,6 @@ class Home(http.Controller):
|
||||
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:
|
||||
@@ -508,6 +504,9 @@ class Home(http.Controller):
|
||||
old_uid = request.uid
|
||||
uid = request.session.authenticate(request.session.db, request.params['login'], request.params['password'])
|
||||
if uid is not False:
|
||||
request.params['login_success'] = True
|
||||
if not redirect:
|
||||
redirect = '/web'
|
||||
return http.redirect_with_hash(redirect)
|
||||
request.uid = old_uid
|
||||
values['error'] = "Wrong login/password"
|
||||
|
||||
@@ -45,10 +45,20 @@ class Website(openerp.addons.web.controllers.main.Home):
|
||||
return request.registry['ir.http'].reroute(first_menu.url)
|
||||
return self.page(page)
|
||||
|
||||
#------------------------------------------------------
|
||||
# Login - overwrite of the web login so that regular users are redirected to the backend
|
||||
# while portal users are redirected to the frontend by default
|
||||
#------------------------------------------------------
|
||||
@http.route(website=True, auth="public")
|
||||
def web_login(self, *args, **kw):
|
||||
# TODO: can't we just put auth=public, ... in web client ?
|
||||
return super(Website, self).web_login(*args, **kw)
|
||||
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
|
||||
|
||||
@http.route('/page/<page:page>', type='http', auth="public", website=True)
|
||||
def page(self, page, **opt):
|
||||
|
||||
Reference in New Issue
Block a user