[FIX] Restore /login redirection on SessionExpired
The feature was broken due to an incompatibility when forward porting624f256
anda78e27f
This commit is contained in:
parent
fc5c53ca47
commit
c981d068ab
|
@ -54,10 +54,14 @@ class ir_http(orm.AbstractModel):
|
|||
request.website_multilang = request.website_enabled and func and func.routing.get('multilang', True)
|
||||
|
||||
if request.website_enabled:
|
||||
if func:
|
||||
self._authenticate(func.routing['auth'])
|
||||
else:
|
||||
self._auth_method_public()
|
||||
try:
|
||||
if func:
|
||||
self._authenticate(func.routing['auth'])
|
||||
else:
|
||||
self._auth_method_public()
|
||||
except Exception as e:
|
||||
return self._handle_exception(e)
|
||||
|
||||
request.redirect = lambda url: werkzeug.utils.redirect(url_for(url))
|
||||
request.website = request.registry['website'].get_current_website(request.cr, request.uid, context=request.context)
|
||||
if first_pass:
|
||||
|
|
|
@ -58,12 +58,6 @@ class ir_http(osv.AbstractModel):
|
|||
def _auth_method_user(self):
|
||||
request.uid = request.session.uid
|
||||
if not request.uid:
|
||||
if not request.params.get('noredirect'):
|
||||
query = werkzeug.url_encode({
|
||||
'redirect': request.httprequest.url,
|
||||
})
|
||||
response = werkzeug.utils.redirect('/web/login?%s' % query)
|
||||
werkzeug.exceptions.abort(response)
|
||||
raise http.SessionExpiredException("Session expired")
|
||||
|
||||
def _auth_method_none(self):
|
||||
|
@ -97,7 +91,10 @@ class ir_http(osv.AbstractModel):
|
|||
|
||||
def _handle_exception(self, exception):
|
||||
# If handle_exception returns something different than None, it will be used as a response
|
||||
return request._handle_exception(exception)
|
||||
try:
|
||||
return request._handle_exception(exception)
|
||||
except openerp.exceptions.AccessDenied:
|
||||
return werkzeug.exceptions.Forbidden()
|
||||
|
||||
def _dispatch(self):
|
||||
# locate the controller method
|
||||
|
@ -110,11 +107,8 @@ class ir_http(osv.AbstractModel):
|
|||
# check authentication level
|
||||
try:
|
||||
auth_method = self._authenticate(func.routing["auth"])
|
||||
except Exception:
|
||||
# force a Forbidden exception with the original traceback
|
||||
return self._handle_exception(
|
||||
convert_exception_to(
|
||||
werkzeug.exceptions.Forbidden))
|
||||
except Exception as e:
|
||||
return self._handle_exception(e)
|
||||
|
||||
processing = self._postprocess_args(arguments, rule)
|
||||
if processing:
|
||||
|
|
|
@ -542,6 +542,12 @@ class HttpRequest(WebRequest):
|
|||
be used as response."""
|
||||
try:
|
||||
return super(HttpRequest, self)._handle_exception(exception)
|
||||
except SessionExpiredException:
|
||||
if not request.params.get('noredirect'):
|
||||
query = werkzeug.urls.url_encode({
|
||||
'redirect': request.httprequest.url,
|
||||
})
|
||||
return werkzeug.utils.redirect('/web/login?%s' % query)
|
||||
except werkzeug.exceptions.HTTPException, e:
|
||||
return e
|
||||
|
||||
|
|
Loading…
Reference in New Issue