Redirection vers url passée en paramètre « came_from » lors de l'inscription.
authorBenoît Pin <pin@cri.ensmp.fr>
Tue, 28 Apr 2015 15:28:54 +0000 (17:28 +0200)
committerBenoît Pin <pin@cri.ensmp.fr>
Tue, 28 Apr 2015 15:28:54 +0000 (17:28 +0200)
Products/Plinn/skins/custom_generic/join_form.py
Products/Plinn/skins/custom_generic/join_template.pt
Products/Plinn/skins/custom_generic/logged_in.py

index 8e82159..f7cdead 100644 (file)
@@ -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:
index d5deaca..eb33650 100644 (file)
@@ -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>
                 </td>
               </tr>
             </table>
+            <input type="hidden" name="came_from"
+                   tal:attributes="value options/came_from"/>
           </form>
           <script type="text/javascript">
             (function(){
index c4663c4..a13d7c7 100755 (executable)
@@ -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)