[sagenb] 35/157: Update settings.py

felix salfelder felix-guest at moszumanska.debian.org
Mon Dec 22 16:51:46 UTC 2014


This is an automated email from the git hooks/post-receive script.

felix-guest pushed a commit to branch master
in repository sagenb.

commit b7ba2f235a255e3254e80deb8bdb9d8ceca69a41
Author: Kapil Hari Paranjape <kapil.paranjape at gmail.com>
Date:   Thu Aug 28 23:41:26 2014 +0530

    Update settings.py
    
    Make 'settings_page' function check password and e-mail for validity as required by the 'login' function in authentication.py
    for the password.
---
 sagenb/flask_version/settings.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/sagenb/flask_version/settings.py b/sagenb/flask_version/settings.py
index 86d6c87..5a90a44 100644
--- a/sagenb/flask_version/settings.py
+++ b/sagenb/flask_version/settings.py
@@ -9,6 +9,8 @@ settings = Module('sagenb.flask_version.settings')
 @login_required
 @with_lock
 def settings_page():
+    from sagenb.notebook.misc import is_valid_password, is_valid_email
+
     error = None
     redirect_to_home = None
     redirect_to_logout = None
@@ -30,6 +32,8 @@ def settings_page():
             error = 'Incorrect password given'
         elif not new:
             error = 'New password not given'
+        elif not is_valid_password(new, g.username):
+            error = 'Password not acceptable. Must be 4 to 32 characters and not contain spaces or username.'
         elif not two:
             error = 'Please type in new password again.'
         elif new != two:
@@ -44,9 +48,12 @@ def settings_page():
     if g.notebook.conf()['email']:
         newemail = request.values.get('new-email', None)
         if newemail:
-            nu.set_email(newemail)
-            ##nu.set_email_confirmation(False)
-            redirect_to_home = True
+            if is_valid_email(newemail):
+                nu.set_email(newemail)
+                ##nu.set_email_confirmation(False)
+                redirect_to_home = True
+            else:
+                error = 'Invalid e-mail address.'
 
     if error:
         return current_app.message(error, url_for('settings_page'))

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/sagenb.git



More information about the debian-science-commits mailing list