# HG changeset patch # User Timothy Clemans # Date 1208283304 25200 # Node ID 0bcaa94be437e884f0d598b396331757f797083c # Parent 631bb7b11fe9e45f70f43be6da034543d5f790e0 Add change password functionality diff -r 631bb7b11fe9 -r 0bcaa94be437 sage/server/notebook/notebook.py --- a/sage/server/notebook/notebook.py Tue Apr 15 04:19:13 2008 -0700 +++ b/sage/server/notebook/notebook.py Tue Apr 15 11:15:04 2008 -0700 @@ -1007,6 +1007,7 @@ class Notebook(SageObject): if not pub: entries.insert(2, ('history_window()', 'Log', 'View a log of recent computations')) if not self.user_is_guest(user): + entries.append(('/passwd', 'Change password', 'Change account password')) entries.append(('/logout', 'Sign out', 'Log out of the Sage notebook')) s += self.html_banner_and_control(user, entries) diff -r 631bb7b11fe9 -r 0bcaa94be437 sage/server/notebook/twist.py --- a/sage/server/notebook/twist.py Tue Apr 15 04:19:13 2008 -0700 +++ b/sage/server/notebook/twist.py Tue Apr 15 11:15:04 2008 -0700 @@ -844,6 +844,53 @@ class NotebookSettings(resource.Resource s = notebook.html_notebook_settings() return http.Response(stream = s) +class ChangePasswordPage(resource.PostableResource): + def __init__(self, username): + self.username = username + + def render(self, request): + error = None + if 'Oldpass' in request.args or 'Newpass' in request.args or 'RetypePass' in request.args: + if not 'Oldpass' in request.args: + error = 'Old password not given' + elif not notebook.user(self.username).password_is(request.args['Oldpass'][0]): + error = 'Incorrect password given' + elif not 'Newpass' in request.args: + error = 'New password not given' + elif not 'RetypePass' in request.args: + error = 'Please type in new password again.' + elif request.args['Newpass'][0] != request.args['RetypePass'][0]: + error = 'The passwords you entered do not match.' + + if error: + return http.Response(stream=message(error, '/passwd')) + + notebook.change_password(self.username, request.args['Newpass'][0]) + return http.RedirectResponse('/logout') + else: + s = """

Change Password.

+
+
+
+
+

+ + + + + + +
Old password:
New password: + +
Retype new password: + +
+

+
Cancel
+
+ + """ + return http.Response(stream=s) ######################################################## # Set output type of a cell @@ -1818,6 +1865,7 @@ class UserToplevel(Toplevel): userchild_live_history = LiveHistory userchild_new_worksheet = NewWorksheet userchild_notebook_settings = NotebookSettings + userchild_passwd = ChangePasswordPage userchild_pub = PublicWorksheets userchild_send_to_trash = SendWorksheetToTrash