diff --git a/addons/auth_oauth/controllers/main.py b/addons/auth_oauth/controllers/main.py index f461a675a47..1c38f7f4eae 100644 --- a/addons/auth_oauth/controllers/main.py +++ b/addons/auth_oauth/controllers/main.py @@ -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))