def reset(self): if self.pw_entry.get() != self.confpw_entry.get(): tkMessageBox.showwarning("Reset Failed", "The passwords do not match." " Please re-enter matching passwords.") else: hashedpw = hasher.create_hash(self.pw_entry.get()) database.change_password(self.studentID, hashedpw) self.destroy()
def change_pass_page(): if request.method == 'GET': return render_template("change_password.html") else: current_pass = request.form['current_pass'] new_pass = request.form['new_pass'] double_check = request.form['double_check'] if current_user.password == current_pass: if new_pass == double_check: db.change_password(current_user.id, new_pass) logout_user() return 'Password changed, now log in again.' return redirect('/dj/password_change_form')
def password_reset(username=None): if not current_user.is_admin: return redirect("/") if username is not None: if current_user.id != 'superadmin': check_user = db.DJUser.get(username) if check_user.is_admin and check_user.id != current_user.id: return 'You can\'t reset another admin\'s password.' new_pass = db.change_password(username) if new_pass is not None: return '{}\'s new password is "{}".'.format(username, new_pass) return '{} doesn\'t exist.'.format(username)
def change_password(self, username): """ change password user function change password for user in database if everything succeed """ print "Changing password...." is_valid = False password = None while not is_valid: self.send(actions.PASSWORD_ACTION) password = self.receive() # get password self.send("Repeat password \n") self.send(actions.PASSWORD_ACTION) password_repeat = self.receive() # get repeated password if password_repeat != password: # compare them self.send("Passwords are not the same, try again" ) # passwords not the same continue # prompt for passwords again if passwords.is_password_valid( password): # passwords the same -> check if pass is valid is_valid = True else: self.send( "Password is invalid (should have more than 7 characters," # pass invalid " at last one digit, one lowercase and one uppercase)," # send validate pass rules " try something else.") # password is valid password_hash, salt = passwords.generate_salt(password) # create hash database.change_password( username, password_hash, salt) # change password for user into database self.send( "Password successfully changed \nNow you can log in with a new one" ) # confirm successful action
def change_password(user_id, password): password_salt, password_hash = create_password_salt(password) database.change_password(user_id, password_hash, password_salt)
def add_user(username, email, password): return db.add_user(username, email, password) while True: client_socket, addr = server_socket.accept() print("Connected with ", addr) request = bytes.decode(client_socket.recv(4096), 'utf-8') if 'add_user' in request: x = request.split(',') client_socket.send(bytes(str(db.add_user(x[1], x[2], x[3])), 'utf-8')) elif 'get_user' in request: x = request.split(',') client_socket.send(bytes(str(db.get_user(x[1])), 'utf-8')) elif 'send_message' in request: x = request.split(',') client_socket.send( bytes(str(db.send_message(x[1], x[2], x[3], x[4])), 'utf-8')) elif 'get_contact' in request: x = request.split(',') client_socket.send(bytes(str(db.get_contact(x[1])), 'utf-8')) elif 'change_password' in request: x = request.split(',') client_socket.send(bytes(str(db.change_password(x[1], x[2])), 'utf-8')) elif 'change_status' in request: x = request.split(',') client_socket.send(bytes(str(db.change_status(x[1], x[2])), 'utf-8'))
def change_password(id): addr = input("ENTER NEW PASSWORD") database.change_password(id, addr)
def command_newpass(args): """Change the password of a user.""" new_pass = db.change_password(args['USER']) print('Changed password to "{}".'.format(new_pass))