def set_password(self, username, new_password, encrypt=True): """ EXAMPLES: sage: from sagenb.notebook.user_manager import SimpleUserManager sage: U = SimpleUserManager() sage: U.create_default_users('passpass') sage: U.check_password('admin','passpass') True sage: U.set_password('admin', 'password') sage: U.check_password('admin','password') True sage: U.set_password('admin', 'test'); U.check_password('admin','test') True sage: U.set_password('admin', 'test', encrypt=False); U.password('admin') 'test' """ if encrypt: salt = user.generate_salt() new_password = '******'.format( salt, hashlib.sha256(salt + new_password).hexdigest()) self._passwords[username] = new_password # need to make sure password in the user object is synced # for compatibility only the user object data is stored in the 'users.pickle' self.user(username).set_password(new_password, encrypt=False)
def set_password(self, username, new_password, encrypt = True): """ EXAMPLES: sage: from sagenb.notebook.user_manager import SimpleUserManager sage: U = SimpleUserManager() sage: U.create_default_users('passpass') sage: U.check_password('admin','passpass') True sage: U.set_password('admin', 'password') sage: U.check_password('admin','password') True sage: U.set_password('admin', 'test'); U.check_password('admin','test') True sage: U.set_password('admin', 'test', encrypt=False); U.password('admin') 'test' """ if encrypt: salt = user.generate_salt() new_password = '******'.format(salt, hashlib.sha256(salt + new_password).hexdigest()) self._passwords[username] = new_password # need to make sure password in the user object is synced # for compatibility only the user object data is stored in the 'users.pickle' self.user(username).set_password(new_password, encrypt = False)