Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
5353 Переглядів

I need to redirect the users to custom website login page when anyone tries to access a route with  auth="user". By default Odoo redirects to Odoo back-end login page. I tried the following code, by overriding  _handle_exception(self, exception) in HttpRequest. But still it doesn't work,

from odoo.http import HttpRequest
class WebsiteRequest(HttpRequest):

def _handle_exception(self, exception):
"""Called within an except block to allow converting exceptions
to abitrary responses. Anything returned (except None) will
be used as response."""
try:
return super(WebsiteRequest, self)._handle_exception(exception)
except SessionExpiredException:
redirect = None
req = request.httprequest
if req.method == 'POST':
request.session.save_request_data()
redirect = '/web/proxy/post{r.full_path}'.format(r=req)
elif not request.params.get('noredirect'):
redirect = req.url
if redirect:
query = urls.url_encode({
'redirect': redirect,
})
if 'web' in redirect:
return utils.redirect('/web/login?%s' % query)
else:
return utils.redirect('/login?%s' % query)
except werkzeug.exceptions.HTTPException as e:
return e



Can someone please provide a solution for this? Thanks
Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
0
бер. 15
4985
5
серп. 25
9768
Carrusel en sitios web Вирішено
2
лип. 25
939
4
черв. 25
1053
1
черв. 25
1350