def change_password(): """Change the password of an existing user""" oldPassword = request.form['oldPassword'] newPassword = request.form['newPassword'] if bcrypt.check_password_hash(current_user.passw, oldPassword): hashed = bcrypt.generate_password_hash(newPassword) current_user.passw = hashed current_user.commit_to_session() return serve_response({}) return serve_error('old password does not match', 401)
def log_in(): username = request.form['username'] password = request.form['password'] user = load_user(username) if user: hashed = user.passw if bcrypt.check_password_hash(hashed, password): # everything's gucci login_user(user) return serve_response({}) return serve_error('invalid username or password', 401)
def change_password(): oldPassword = request.form['oldPassword'] newPassword = request.form['newPassword'] if bcrypt.check_password_hash(current_user.passw, oldPassword): hashed = bcrypt.generate_password_hash(newPassword) current_user.passw = hashed session.add(current_user) session.flush() session.commit() return serve_response({}) return serve_error('old password does not match', 401)
def log_in(): username = request.form['username'] password = request.form['password'] user = load_user(username) if user: hashed = user.password if bcrypt.check_password_hash(hashed, password): # everything's gucci login_user(user) Event.log(username, 'login') return serve_response({}) return serve_error('invalid username or password', 401)