[FIX] auth_oauth: redirect to login page in case of failure with an automatic oauth signin, but avoid destroying user session

bzr revid: odo@openerp.com-20130212163301-cnq949vr1h6hfvf5
This commit is contained in:
Olivier Dony
2013-02-12 17:33:01 +01:00
parent 6a88cc0f7b
commit 9d6a4205d0
+9
View File
@@ -2,8 +2,10 @@ import functools
import logging
import simplejson
import werkzeug.utils
from werkzeug.exceptions import BadRequest
import openerp
from openerp import SUPERUSER_ID
import openerp.addons.web.http as oeweb
from openerp.addons.web.controllers.main import db_monodb, set_cookie_and_redirect, login_and_redirect
@@ -69,6 +71,13 @@ class OAuthController(oeweb.Controller):
# auth_signup is not installed
_logger.error("auth_signup not installed on database %s: oauth sign up cancelled." % (dbname,))
url = "/#action=login&oauth_error=1"
except openerp.exceptions.AccessDenied:
# oauth credentials not valid, user could be on a temporary session
_logger.info('OAuth2: access denied, redirect to main page in case a valid session exists, without setting cookies')
url = "/#action=login&oauth_error=3"
redirect = werkzeug.utils.redirect(url, 303)
redirect.autocorrect_location_header = False
return redirect
except Exception, e:
# signup error
_logger.exception("OAuth2: %s" % str(e))