summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addons/auth_oauth/controllers/main.py3
-rw-r--r--addons/auth_signup/controllers/main.py3
-rw-r--r--addons/auth_signup/res_users.py11
-rw-r--r--addons/portal/mail_mail.py2
4 files changed, 15 insertions, 4 deletions
diff --git a/addons/auth_oauth/controllers/main.py b/addons/auth_oauth/controllers/main.py
index b6481f0ca28..6d28813507c 100644
--- a/addons/auth_oauth/controllers/main.py
+++ b/addons/auth_oauth/controllers/main.py
@@ -73,6 +73,9 @@ class OAuthLogin(openerp.addons.web.controllers.main.Home):
@http.route()
def web_login(self, *args, **kw):
+ if request.httprequest.method == 'GET' and request.session.uid and request.params.get('redirect'):
+ # Redirect if already logged in and redirect param is present
+ return http.redirect_with_hash(request.params.get('redirect'))
providers = self.list_providers()
response = super(OAuthLogin, self).web_login(*args, **kw)
diff --git a/addons/auth_signup/controllers/main.py b/addons/auth_signup/controllers/main.py
index 08b67108c3f..92ae6364954 100644
--- a/addons/auth_signup/controllers/main.py
+++ b/addons/auth_signup/controllers/main.py
@@ -37,6 +37,9 @@ class AuthSignup(openerp.addons.web.controllers.main.Home):
mode = request.params.get('mode')
qcontext = request.params.copy()
super_response = None
+ if request.httprequest.method == 'GET' and request.session.uid and request.params.get('redirect'):
+ # Redirect if already logged in and redirect param is present
+ return http.redirect_with_hash(request.params.get('redirect'))
if request.httprequest.method != 'POST' or mode not in ('reset', 'signup'):
# Default behavior is to try to login, which in reset or signup mode in a non-sense.
super_response = super(AuthSignup, self).web_login(*args, **kw)
diff --git a/addons/auth_signup/res_users.py b/addons/auth_signup/res_users.py
index e91af657cc2..32aa22b2744 100644
--- a/addons/auth_signup/res_users.py
+++ b/addons/auth_signup/res_users.py
@@ -20,8 +20,8 @@
##############################################################################
from datetime import datetime, timedelta
import random
-from urllib import urlencode
from urlparse import urljoin
+import werkzeug
from openerp.addons.base.ir.ir_mail_server import MailDeliveryException
from openerp.osv import osv, fields
@@ -53,7 +53,7 @@ class res_partner(osv.Model):
(not partner.signup_expiration or dt <= partner.signup_expiration)
return res
- def _get_signup_url_for_action(self, cr, uid, ids, action='login', view_type=None, menu_id=None, res_id=None, model=None, context=None):
+ def _get_signup_url_for_action(self, cr, uid, ids, action=None, view_type=None, menu_id=None, res_id=None, model=None, context=None):
""" generate a signup url for the given partner ids and action, possibly overriding
the url state components (menu_id, id, view_type) """
if context is None:
@@ -80,6 +80,8 @@ class res_partner(osv.Model):
continue # no signup token, no user, thus no signup url!
fragment = dict()
+ if action:
+ fragment['action'] = action
if view_type:
fragment['view_type'] = view_type
if menu_id:
@@ -89,7 +91,10 @@ class res_partner(osv.Model):
if res_id:
fragment['id'] = res_id
- res[partner.id] = urljoin(base_url, "/web/login?%s#%s" % (urlencode(query), urlencode(fragment)))
+ if fragment:
+ query['redirect'] = '/web#' + werkzeug.url_encode(fragment)
+
+ res[partner.id] = urljoin(base_url, "/web/login?%s" % werkzeug.url_encode(query))
return res
diff --git a/addons/portal/mail_mail.py b/addons/portal/mail_mail.py
index 18eb15361a3..0fe2081fa45 100644
--- a/addons/portal/mail_mail.py
+++ b/addons/portal/mail_mail.py
@@ -39,7 +39,7 @@ class mail_mail(osv.Model):
if partner and not partner.user_ids:
contex_signup = dict(context, signup_valid=True)
signup_url = partner_obj._get_signup_url_for_action(cr, SUPERUSER_ID, [partner.id],
- action='login', model=mail.model, res_id=mail.res_id,
+ model=mail.model, res_id=mail.res_id,
context=contex_signup)[partner.id]
return _("""<span class='oe_mail_footer_access'><small>Access your messages and documents through <a style='color:inherit' href="%s">our Customer Portal</a></small></span>""") % signup_url
else: