[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)
|
request.website_multilang = request.website_enabled and func and func.routing.get('multilang', True)
|
||||||
|
|
||||||
if request.website_enabled:
|
if request.website_enabled:
|
||||||
if func:
|
try:
|
||||||
self._authenticate(func.routing['auth'])
|
if func:
|
||||||
else:
|
self._authenticate(func.routing['auth'])
|
||||||
self._auth_method_public()
|
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.redirect = lambda url: werkzeug.utils.redirect(url_for(url))
|
||||||
request.website = request.registry['website'].get_current_website(request.cr, request.uid, context=request.context)
|
request.website = request.registry['website'].get_current_website(request.cr, request.uid, context=request.context)
|
||||||
if first_pass:
|
if first_pass:
|
||||||
|
|
|
@ -58,12 +58,6 @@ class ir_http(osv.AbstractModel):
|
||||||
def _auth_method_user(self):
|
def _auth_method_user(self):
|
||||||
request.uid = request.session.uid
|
request.uid = request.session.uid
|
||||||
if not request.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")
|
raise http.SessionExpiredException("Session expired")
|
||||||
|
|
||||||
def _auth_method_none(self):
|
def _auth_method_none(self):
|
||||||
|
@ -97,7 +91,10 @@ class ir_http(osv.AbstractModel):
|
||||||
|
|
||||||
def _handle_exception(self, exception):
|
def _handle_exception(self, exception):
|
||||||
# If handle_exception returns something different than None, it will be used as a response
|
# 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):
|
def _dispatch(self):
|
||||||
# locate the controller method
|
# locate the controller method
|
||||||
|
@ -110,11 +107,8 @@ class ir_http(osv.AbstractModel):
|
||||||
# check authentication level
|
# check authentication level
|
||||||
try:
|
try:
|
||||||
auth_method = self._authenticate(func.routing["auth"])
|
auth_method = self._authenticate(func.routing["auth"])
|
||||||
except Exception:
|
except Exception as e:
|
||||||
# force a Forbidden exception with the original traceback
|
return self._handle_exception(e)
|
||||||
return self._handle_exception(
|
|
||||||
convert_exception_to(
|
|
||||||
werkzeug.exceptions.Forbidden))
|
|
||||||
|
|
||||||
processing = self._postprocess_args(arguments, rule)
|
processing = self._postprocess_args(arguments, rule)
|
||||||
if processing:
|
if processing:
|
||||||
|
|
|
@ -542,6 +542,12 @@ class HttpRequest(WebRequest):
|
||||||
be used as response."""
|
be used as response."""
|
||||||
try:
|
try:
|
||||||
return super(HttpRequest, self)._handle_exception(exception)
|
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:
|
except werkzeug.exceptions.HTTPException, e:
|
||||||
return e
|
return e
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue