[FIX] signup/reset urls and redirect if already logged in and redirect in request.params
bzr revid: fme@openerp.com-20140319155333-zt0np33m1361pyk3
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user