[CMF-checkins] SVN: CMF/trunk/C - refactored logged_in page and password_form

Yvo Schubbe y.2006_ at wcm-solutions.de
Fri Feb 10 04:16:28 EST 2006


Log message for revision 41588:
  - refactored logged_in page and password_form

Changed:
  U   CMF/trunk/CHANGES.txt
  UU  CMF/trunk/CMFDefault/skins/zpt_control/change_password.py
  D   CMF/trunk/CMFDefault/skins/zpt_generic/logged_in.pt
  A   CMF/trunk/CMFDefault/skins/zpt_generic/logged_in.py
  A   CMF/trunk/CMFDefault/skins/zpt_generic/logged_in_template.pt
  D   CMF/trunk/CMFDefault/skins/zpt_generic/password_form.pt
  A   CMF/trunk/CMFDefault/skins/zpt_generic/password_form.py
  A   CMF/trunk/CMFDefault/skins/zpt_generic/password_form_template.pt
  UU  CMF/trunk/CMFDefault/skins/zpt_generic/zpt_stylesheet.css

-=-
Modified: CMF/trunk/CHANGES.txt
===================================================================
--- CMF/trunk/CHANGES.txt	2006-02-10 09:10:18 UTC (rev 41587)
+++ CMF/trunk/CHANGES.txt	2006-02-10 09:16:28 UTC (rev 41588)
@@ -134,6 +134,10 @@
 
   Bug Fixes
 
+    - CMFDefault skins: Refactored 'logged_in' page and 'password_form'.
+      'logged_in' now redirects to the 'password_form' if a new member has to
+      change her password.
+
     - CMFDefault skins: Fixed clipboard data validation.
       Split off validateClipboardData from folder_paste_control.
 

Modified: CMF/trunk/CMFDefault/skins/zpt_control/change_password.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_control/change_password.py	2006-02-10 09:10:18 UTC (rev 41587)
+++ CMF/trunk/CMFDefault/skins/zpt_control/change_password.py	2006-02-10 09:16:28 UTC (rev 41588)
@@ -1,16 +1,21 @@
-## Script (Python) "change_password"
+##parameters=password, confirm, domains=None, **kw
 ##title=Action to change password
-##parameters=password, confirm, domains=None
-mt = context.portal_membership
-failMessage=context.portal_registration.testPasswordValidity(password, confirm)
+##
+from Products.CMFCore.utils import getToolByName
+from Products.CMFDefault.utils import Message as _
 
-if failMessage:
-  return context.password_form(context,
-                               context.REQUEST,
-                               error=failMessage)
-member = mt.getAuthenticatedMember()
-mt.setPassword(password, domains)
-mt.credentialsChanged(password)
-return context.personalize_form(context,
-                                context.REQUEST,
-                                portal_status_message='Password changed.')
+mtool = getToolByName(script, 'portal_membership')
+rtool = getToolByName(script, 'portal_registration')
+
+result = rtool.testPasswordValidity(password, confirm)
+if result:
+    return context.setStatus(False, result)
+
+member = mtool.getAuthenticatedMember()
+mtool.setPassword(password, domains)
+if member.getProperty('last_login_time').Date() == '1999/01/01':
+    member.setProperties(last_login_time='2000/01/01')
+
+mtool.credentialsChanged(password)
+    
+return context.setStatus(True, _(u'Password changed.'))


Property changes on: CMF/trunk/CMFDefault/skins/zpt_control/change_password.py
___________________________________________________________________
Name: svn:keywords
   - Author Date Id Revision

Deleted: CMF/trunk/CMFDefault/skins/zpt_generic/logged_in.pt
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/logged_in.pt	2006-02-10 09:10:18 UTC (rev 41587)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/logged_in.pt	2006-02-10 09:16:28 UTC (rev 41588)
@@ -1,133 +0,0 @@
-<tal:block tal:condition="here/portal_skins/updateSkinCookie | nothing"
-           tal:define="dummy here/setupCurrentSkin" />
-
-<html xmlns:tal="http://xml.zope.org/namespaces/tal"
-      xmlns:metal="http://xml.zope.org/namespaces/metal"
-      metal:use-macro="here/main_template/macros/master">
-<body>
-
-<div metal:fill-slot="main" i18n:domain="cmf_default">
-
- <div tal:define="p_props here/portal_properties;
-                  p_url here/portal_url;
-                  mtool here/portal_membership;
-                  isAnon mtool/isAnonymousUser|nothing;
-                  member mtool/getAuthenticatedMember;
-                  now here/ZopeTime;
-                  never string:2000/01/01;
-                 "
- >
-
-  <div tal:condition="isAnon">
-
-   <span tal:define="dummy python:request['RESPONSE'].expireCookie('__ac'
-                                                                  , path='/')"
-   />
-
-   <h1 class="DesktopTitle" i18n:translate="">Login failure</h1>
-
-   <p class="Desktop" i18n:translate="">You are not currently logged in. Your
-     username and or password may be incorrect. Your browser may also not be
-     configured to accept HTTP cookies. If you need help please contact
-      <a href="mailto:admin at here.com" title="Email Admin"
-         tal:attributes="href string:mailto:${p_props/email_from_address}"
-         tal:content="p_props/email_from_address"
-         i18n:name="admin_email">Email Admin</a>.
-   </p>
-  </div><!-- isAnon -->
-
-  <div tal:condition="not: isAnon"
-       tal:define="first_time python:(
-                    member.getProperty( 'login_time', None ) == never
-                                       and p_props.validate_email );
-                   dum_home mtool/createMemberArea">
-
-   <div tal:condition="first_time">
-    <div tal:define="dum_reg python:member.setProperties(
-                                                last_login_time=now,
-                                                login_time=now)" />
-
-    <h1 class="DesktopTitle" i18n:translate="">Welcome!</h1>
-
-    <p class="Desktop" i18n:translate="">
-       This is the first time that you've logged in to
-       <span tal:replace="p_props/title" i18n:name="portal_title">Here</span>.
-       Before you start exploring you need to change your original password.
-       This will ensure that the password we sent you via email cannot be
-       used in a malicious manner.</p>
-
-    <p class="Desktop" i18n:translate="">
-       Please use the form below to change your password.</p>
-
-    <form action="change_password" method="post"
-          tal:attributes="action string:${p_url}/change_password"
-    >
-     <input type="hidden" name="user" value=""
-            tal:attributes="value member" />
-     <input type="hidden" name="domains:tokens" value="" />
-     <input type="hidden" name="redirect" value=""
-            tal:attributes="value string:${p_url}/" />
-
-     <table>
-
-      <tr valign="top" align="left">
-       <th i18n:translate="">Username</th>
-       <td><span tal:replace="member">You</span></td>
-      </tr>
-
-      <tr valign="top"  align="left">
-       <th i18n:translate="">New password</th>
-       <td><input type="password" name="password" /></td>
-      </tr>
-
-      <tr valign="top"  align="left">
-       <th i18n:translate="">Confirm new password</th>
-       <td><input type="password" name="confirm" /></td>
-      </tr>
-
-      <tr>
-       <td><br /></td>
-       <td>
-        <input type="submit" value="Change password"
-               i18n:attributes="value" />
-       </td>
-      </tr>
-
-     </table>
-
-    </form>
-
-   </div><!-- first_time -->
-
-   <div tal:condition="not: first_time">
-
-    <div tal:define="d_reg python:member.setProperties(
-                                           last_login_time=member.login_time);
-                     ereg python:member.setProperties(
-                                            login_time=here.ZopeTime());
-                    " />
-
-    <div tal:condition="request/came_from | nothing ">
-      <div tal:define="came_from python:request.get('came_from');
-                       response request/RESPONSE;
-                       dredirect python: response.redirect(came_from);
-                      " />
-    </div>
-
-    <h1 class="DesktopTitle" i18n:translate="">Login success</h1>
-
-    <p class="Desktop" i18n:translate="">Welcome. You are currently logged
-      in.</p>
-
-   </div><!-- not first_time -->
-
-  </div><!-- not isAnon -->
-
- </div><!-- define p_props -->
-
-</div><!-- metal:fill-slot="main" -->
-
-</body>
-</html>
-
-

Added: CMF/trunk/CMFDefault/skins/zpt_generic/logged_in.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/logged_in.py	2006-02-10 09:10:18 UTC (rev 41587)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/logged_in.py	2006-02-10 09:16:28 UTC (rev 41588)
@@ -0,0 +1,48 @@
+##parameters=
+##
+from Products.CMFCore.utils import getToolByName
+from Products.CMFDefault.utils import decode
+from Products.CMFDefault.utils import Message as _
+
+mtool = getToolByName(script, 'portal_membership')
+ptool = getToolByName(script, 'portal_properties')
+stool = getToolByName(script, 'portal_skins')
+utool = getToolByName(script, 'portal_url')
+portal_url = utool()
+
+
+if stool.updateSkinCookie():
+    context.setupCurrentSkin()
+
+
+options = {}
+
+isAnon = mtool.isAnonymousUser()
+if isAnon:
+    context.REQUEST.RESPONSE.expireCookie('__ac', path='/')
+    options['is_anon'] = True
+    options['title'] = _(u'Login failure')
+    options['admin_email'] = ptool.getProperty('email_from_address')
+else:
+    mtool.createMemberArea()
+    member = mtool.getAuthenticatedMember()
+    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:
+            context.REQUEST.RESPONSE.redirect(came_from)
+            return
+        options['is_anon'] = False
+        options['title'] = _(u'Login success')
+
+return context.logged_in_template(**decode(options, script))


Property changes on: CMF/trunk/CMFDefault/skins/zpt_generic/logged_in.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Copied: CMF/trunk/CMFDefault/skins/zpt_generic/logged_in_template.pt (from rev 41570, CMF/trunk/CMFDefault/skins/zpt_generic/logged_in.pt)
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/logged_in.pt	2006-02-05 22:06:02 UTC (rev 41570)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/logged_in_template.pt	2006-02-10 09:16:28 UTC (rev 41588)
@@ -0,0 +1,24 @@
+<html metal:use-macro="context/main_template/macros/master">
+<body>
+
+<metal:slot metal:fill-slot="header" i18n:domain="cmf_default">
+<h1 tal:content="options/title">Title</h1>
+</metal:slot>
+
+<metal:slot metal:fill-slot="main" i18n:domain="cmf_default">
+<tal:case tal:condition="options/is_anon">
+<p i18n:translate="">You are not currently logged in. Your username and or
+ password may be incorrect. Your browser may also not be configured to accept
+ HTTP cookies. If you need help please contact
+ <a href="mailto:admin at example.org" title="Email Admin"
+    tal:attributes="href string:mailto:${options/admin_email}"
+    tal:content="options/admin_email"
+    i18n:name="admin_email">admin at example.org</a>.</p>
+</tal:case>
+<tal:case tal:condition="not: options/is_anon">
+<p i18n:translate="">Welcome. You are currently logged in.</p>
+</tal:case>
+</metal:slot>
+
+</body>
+</html>


Property changes on: CMF/trunk/CMFDefault/skins/zpt_generic/logged_in_template.pt
___________________________________________________________________
Name: svn:eol-style
   + native

Deleted: CMF/trunk/CMFDefault/skins/zpt_generic/password_form.pt
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/password_form.pt	2006-02-10 09:10:18 UTC (rev 41587)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/password_form.pt	2006-02-10 09:16:28 UTC (rev 41588)
@@ -1,56 +0,0 @@
-<html xmlns:tal="http://xml.zope.org/namespaces/tal"
-      xmlns:metal="http://xml.zope.org/namespaces/metal"
-      metal:use-macro="here/main_template/macros/master">
-<body>
-<div metal:fill-slot="main" i18n:domain="cmf_default">
-  <div tal:define="member python: here.portal_membership.getAuthenticatedMember()">
-<div class="Desktop">
-
-<h1 i18n:translate="">Change your Password</h1>
-<div class="error"
-     tal:replace="request/error"
-     tal:condition="request/error|nothing"><hr /></div>
-
-<form action="change_password" method="post"
-      tal:attributes="action string:${here/absolute_url}/change_password"
->
-<table class="FormLayout">
- <tr>
-  <th i18n:translate="">Username</th>
-  <td><span tal:replace="member/getUserName">You</span>
-  </td>
- </tr>
- <tr>
-  <th i18n:translate="">New password</th>
-  <td><input type="password" name="password" />
-  </td>
- </tr>
- <tr>
-  <th i18n:translate="">Confirm new password</th>
-  <td><input type="password" name="confirm" />
-  </td>
- </tr>
- <tr>
-  <th i18n:translate="">Domains</th>
-  <td>
-    <input type="text" name="domains:tokens" value="" /><br />
-    <em i18n:translate="">If you do not know what this field is for, leave it
-    blank.</em>
-  </td>
- </tr>
- <tr>
-  <td><br /></td>
-  <td>
-   <input type="submit" value="Change" i18n:attributes="value" />
-  </td>
- </tr>
-</table>
-</form>
-
-</div>
-</div>
-
-</div>
-</body>
-</html>
-

Added: CMF/trunk/CMFDefault/skins/zpt_generic/password_form.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/password_form.py	2006-02-10 09:10:18 UTC (rev 41587)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/password_form.py	2006-02-10 09:16:28 UTC (rev 41588)
@@ -0,0 +1,43 @@
+##parameters=change='', cancel=''
+##
+from Products.CMFCore.utils import getToolByName
+from Products.CMFDefault.utils import decode
+from Products.CMFDefault.utils import Message as _
+
+atool = getToolByName(script, 'portal_actions')
+mtool = getToolByName(script, 'portal_membership')
+ptool = getToolByName(script, 'portal_properties')
+utool = getToolByName(script, 'portal_url')
+member = mtool.getAuthenticatedMember()
+portal_url = utool()
+
+form = context.REQUEST.form
+if change and \
+        context.change_password(**form) and \
+        context.setRedirect(atool, 'user/preferences'):
+    return
+elif cancel and \
+        context.setRedirect(atool, 'user/preferences'):
+    return
+
+
+options = {}
+
+is_first_login = (member.getProperty('last_login_time').Date() == '1999/01/01')
+options['is_first_login'] = is_first_login
+if is_first_login:
+    options['title'] = _(u'Welcome!')
+    options['portal_title'] = ptool.getProperty('title')
+else:
+    options['title'] = _(u'Change your Password')
+options['member_id'] = member.getId()
+options['domains'] = ' '.join(member.getDomains())
+buttons = []
+target = '%s/password_form' % portal_url
+buttons.append( {'name': 'change', 'value': _(u'Change')} )
+if not is_first_login:
+    buttons.append( {'name': 'cancel', 'value': _(u'Cancel')} )
+options['form'] = { 'action': target,
+                    'listButtonInfos': tuple(buttons) }
+
+return context.password_form_template(**decode(options, script))


Property changes on: CMF/trunk/CMFDefault/skins/zpt_generic/password_form.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Copied: CMF/trunk/CMFDefault/skins/zpt_generic/password_form_template.pt (from rev 41570, CMF/trunk/CMFDefault/skins/zpt_generic/password_form.pt)
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/password_form.pt	2006-02-05 22:06:02 UTC (rev 41570)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/password_form_template.pt	2006-02-10 09:16:28 UTC (rev 41588)
@@ -0,0 +1,57 @@
+<html metal:use-macro="context/main_template/macros/master">
+<body>
+
+<metal:slot metal:fill-slot="header" i18n:domain="cmf_default">
+<h1 tal:content="options/title">Title</h1>
+</metal:slot>
+
+<metal:slot metal:fill-slot="main" i18n:domain="cmf_default"
+   tal:define="form options/form">
+
+<tal:case tal:condition="options/is_first_login">
+<p i18n:translate="">This is the first time that you've logged in to
+ <tal:span tal:content="options/portal_title"
+    i18n:name="portal_title">Here</tal:span>.
+ Before you start exploring you need to change your original password. This
+ will ensure that the password we sent you via email cannot be used in a
+ malicious manner.</p>
+
+<p i18n:translate="">Please use the form below to change your password.</p>
+</tal:case>
+
+<form action="password_form" method="post"
+   tal:attributes="action form/action">
+<table class="FormLayout">
+ <tr>
+  <th i18n:translate="">Member ID</th>
+  <td><span tal:replace="options/member_id">You</span></td>
+ </tr>
+ <tr>
+  <th i18n:translate="">New password</th>
+  <td><input type="password" name="password" /></td>
+ </tr>
+ <tr>
+  <th i18n:translate="">Confirm new password</th>
+  <td><input type="password" name="confirm" /></td>
+ </tr>
+ <tr>
+  <th i18n:translate="">Domains</th>
+  <td>
+   <input type="text" name="domains:tokens" value=""
+      tal:attributes="value options/domains" /><br />
+    <em i18n:translate="">If you do not know what this field is for, leave it
+    blank.</em>
+  </td>
+ </tr>
+ <tr>
+  <td>&nbsp;</td>
+  <td>
+   <metal:macro metal:use-macro="context/form_widgets/macros/buttons" />
+  </td>
+ </tr>
+</table>
+</form>
+</metal:slot>
+
+</body>
+</html>


Property changes on: CMF/trunk/CMFDefault/skins/zpt_generic/password_form_template.pt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: CMF/trunk/CMFDefault/skins/zpt_generic/zpt_stylesheet.css
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/zpt_stylesheet.css	2006-02-10 09:10:18 UTC (rev 41587)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/zpt_stylesheet.css	2006-02-10 09:16:28 UTC (rev 41588)
@@ -244,6 +244,9 @@
 }
 
 table.FormLayout th {
+    width: 72pt;
+    padding-right: 8pt;
+    vertical-align: top;
     text-align: right;
     font-size: 80%;
     font-weight: bold;


Property changes on: CMF/trunk/CMFDefault/skins/zpt_generic/zpt_stylesheet.css
___________________________________________________________________
Name: svn:keywords
   - Author Date Id Revision



More information about the CMF-checkins mailing list