From f9f1aa2535d3fae8e35d803ba8c85f8891ec133c Mon Sep 17 00:00:00 2001
From: =?utf8?q?Benoi=CC=82t=20Pin?= <pin@cri.ensmp.fr>
Date: Tue, 28 Apr 2015 17:28:54 +0200
Subject: [PATCH] =?utf8?q?Redirection=20vers=20url=20pass=C3=A9e=20en=20pa?=
 =?utf8?q?ram=C3=A8tre=20=C2=AB=C2=A0came=5Ffrom=C2=A0=C2=BB=20lors=20de?=
 =?utf8?q?=20l'inscription.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit

---
 .../Plinn/skins/custom_generic/join_form.py   |  3 ++-
 .../skins/custom_generic/join_template.pt     |  3 +++
 .../Plinn/skins/custom_generic/logged_in.py   | 24 +++++--------------
 3 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/Products/Plinn/skins/custom_generic/join_form.py b/Products/Plinn/skins/custom_generic/join_form.py
index 8e82159..f7cdead 100644
--- a/Products/Plinn/skins/custom_generic/join_form.py
+++ b/Products/Plinn/skins/custom_generic/join_form.py
@@ -1,4 +1,4 @@
-##parameters=member_id='', given_name='', name='', member_email='', password='', confirm='', add='', ajax=''
+##parameters=member_id='', given_name='', name='', member_email='', password='', confirm='', add='', came_from='', ajax=''
 ##
 from Products.CMFCore.utils import getToolByName
 from Products.CMFDefault.permissions import ManageUsers
@@ -58,6 +58,7 @@ options['isOrdinaryMember'] = not (mtool.isAnonymousUser() or is_newmember)
 options['validate_email'] = validate_email
 options['isAnonRegistration'] = rtool.getMode() == MODE_ANONYMOUS
 options['isReviewedRegistration'] = rtool.getMode() == MODE_REVIEWED
+options['came_from'] = came_from
 
 buttons = []
 if is_newmember:
diff --git a/Products/Plinn/skins/custom_generic/join_template.pt b/Products/Plinn/skins/custom_generic/join_template.pt
index d5deaca..eb33650 100644
--- a/Products/Plinn/skins/custom_generic/join_template.pt
+++ b/Products/Plinn/skins/custom_generic/join_template.pt
@@ -30,6 +30,7 @@
             <form tal:attributes="action form/action" method="post">
               <input type="hidden" name="__ac_name" tal:attributes="value options/member_id"/>
               <input type="hidden" name="__ac_password" tal:attributes="value options/password"/>
+              <input type="hidden" name="came_from" tal:attributes="value options/came_from">
               <input type="hidden" name="noAjax" value="1"/>
               <metal:macro metal:use-macro="context/form_widgets/macros/buttons"/>
             </form>
@@ -108,6 +109,8 @@
                 </td>
               </tr>
             </table>
+            <input type="hidden" name="came_from"
+                   tal:attributes="value options/came_from"/>
           </form>
           <script type="text/javascript">
             (function(){
diff --git a/Products/Plinn/skins/custom_generic/logged_in.py b/Products/Plinn/skins/custom_generic/logged_in.py
index c4663c4..a13d7c7 100755
--- a/Products/Plinn/skins/custom_generic/logged_in.py
+++ b/Products/Plinn/skins/custom_generic/logged_in.py
@@ -33,21 +33,9 @@ else:
 	now = context.ZopeTime()
 	last_login = member.getProperty('login_time', None)
 	member.setProperties(last_login_time=last_login, login_time=now)
-	is_first_login = (last_login == '2000/01/01' and
-					  ptool.getProperty('validate_email'))
-	if is_first_login:
-		member.setProperties(last_login_time='1999/01/01', login_time=now)
-		target = '%s/password_form' % portal_url
-		context.REQUEST.RESPONSE.redirect(target)
-		return
-	else:
-		member.setProperties(last_login_time=last_login, login_time=now)
-		came_from = context.REQUEST.get('came_from', None)
-		if came_from:
-			return context.REQUEST.RESPONSE.redirect(came_from)
-		else :
-			url = atool.getActionInfo('user/logged_in', object=portal)['url']
-			url = '%s?%s' %(url, mq(portal_status_message=_('Login success')))
-			return context.REQUEST.RESPONSE.redirect(url)
-
-return context.logged_in_template(**decode(options, script))
+	came_from = context.REQUEST.get('came_from', None)
+	if came_from:
+		return context.REQUEST.RESPONSE.redirect(came_from)
+	else :
+		url = '%s?%s' %(portal_url, mq(portal_status_message=_('Login success')))
+		return context.REQUEST.RESPONSE.redirect(url)
-- 
2.20.1