changeset 2918:70d113e58edc

merged
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 27 Apr 2015 21:53:38 +0200
parents df1ea9450914 (current diff) eb4e31a57a3a (diff)
children 3862a0aede87
files MoinMoin/static/js/common.js MoinMoin/templates/usersettings_forms.html
diffstat 5 files changed, 21 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/app.py	Mon Apr 27 21:18:24 2015 +0200
+++ b/MoinMoin/app.py	Mon Apr 27 21:53:38 2015 +0200
@@ -208,7 +208,12 @@
     flaskg._login_messages = []
 
     # first try setting up from session
-    userobj = auth.setup_from_session()
+    try:
+        userobj = auth.setup_from_session()
+    except KeyError:
+        # error caused due to invalid cookie, recreating session
+        session.clear()
+        userobj = auth.setup_from_session()
 
     # then handle login/logout forms
     form = request.values.to_dict()
--- a/MoinMoin/apps/frontend/views.py	Mon Apr 27 21:18:24 2015 +0200
+++ b/MoinMoin/apps/frontend/views.py	Mon Apr 27 21:53:38 2015 +0200
@@ -1270,7 +1270,7 @@
     """a simple user registration form"""
     name = 'register'
 
-    username = RequiredText.using(label=L_('Name')).with_properties(placeholder=L_("The login name you want to use"))
+    username = RequiredText.using(label=L_('Username')).with_properties(placeholder=L_("The login username you want to use"))
     password1 = RequiredPassword.with_properties(placeholder=L_("The login password you want to use"))
     password2 = RequiredPassword.with_properties(placeholder=L_("Repeat the same password"))
     email = YourEmail
@@ -1556,7 +1556,7 @@
     """
     name = 'login'
 
-    username = RequiredText.using(label=L_('Name'), optional=False).with_properties(autofocus=True)
+    username = RequiredText.using(label=L_('Username'), optional=False).with_properties(autofocus=True)
     password = RequiredPassword
     openid = YourOpenID.using(optional=True)
     # This field results in a login_submit field in the POST form, which is in
@@ -1612,6 +1612,8 @@
     password_problem_msg = L_('New password is unacceptable, could not get processed.')
 
     def validate(self, element, state):
+        password_not_accepted_msg = L_('New password not acceptable: ')
+
         if not (element['password_current'].valid and element['password1'].valid and element['password2'].valid):
             return False
 
@@ -1622,6 +1624,11 @@
             return self.note_error(element, state, 'passwords_mismatch_msg')
 
         password = element['password1'].value
+        pw_checker = app.cfg.password_checker
+        if pw_checker:
+            pw_error = pw_checker(flaskg.user.name[0], password)
+            if pw_error:
+                return self.note_error(element, state, message=password_not_accepted_msg + pw_error)
         try:
             app.cfg.cache.pwd_context.encrypt(password)
         except (ValueError, TypeError) as err:
@@ -1680,7 +1687,7 @@
     # these forms can't be global because we need app object, which is only available within a request:
     class UserSettingsPersonalForm(Form):
         name = 'usersettings_personal'  # "name" is duplicate
-        name = Names.using(label=L_('Names')).with_properties(placeholder=L_("The login names you want to use"))
+        name = Names.using(label=L_('Usernames')).with_properties(placeholder=L_("The login usernames you want to use"))
         display_name = OptionalText.using(label=L_('Display-Name')).with_properties(
             placeholder=L_("Your display name (informational)"))
         openid = YourOpenID.using(optional=True)
--- a/MoinMoin/static/js/common.js	Mon Apr 27 21:18:24 2015 +0200
+++ b/MoinMoin/static/js/common.js	Mon Apr 27 21:53:38 2015 +0200
@@ -378,8 +378,8 @@
             newform.data('initialForm', newform.serialize());
             // replace the old form with the new one
             form.replaceWith(newform);
-            if (ev.currentTarget.name === 'usersettings_ui') {
-                // theme has changed, show user the new theme
+            if (ev.currentTarget.name === 'usersettings_ui' ||  ev.currentTarget.id === 'usersettings_personal') {
+                // theme or language may have changed, show user the new theme/language
                 location.reload(true);
             }
         }, 'json');
--- a/MoinMoin/templates/mychanges.html	Mon Apr 27 21:18:24 2015 +0200
+++ b/MoinMoin/templates/mychanges.html	Mon Apr 27 21:53:38 2015 +0200
@@ -55,5 +55,7 @@
                 </tbody>
             </table>
         </div>
+    {% else %}
+        <p class='moin-flash moin-flash-javascript moin-flash-error'>No changes detected</p>
     {% endif %}
 {% endblock %}
--- a/MoinMoin/templates/usersettings_forms.html	Mon Apr 27 21:18:24 2015 +0200
+++ b/MoinMoin/templates/usersettings_forms.html	Mon Apr 27 21:53:38 2015 +0200
@@ -1,7 +1,7 @@
 {% import "forms.html" as forms %}
 
 {% macro personal(form) %}
-    {{ gen.form.open(form, method="post", action=url_for('frontend.usersettings')) }}
+    {{ gen.form.open(form, id="usersettings_personal", method="post", action=url_for('frontend.usersettings')) }}
         {{ forms.render_errors(form) }}
         <dl>
             {{ forms.render(form['name']) }}