def delete_user(_admin_user):
    params = assert_data_has_keys(request, {'email'})
    user = User.from_db_row(user_data_by_email(params['email']))
    delete_user_by_id(user.id)
    all_users = [User.from_db_row(r).to_dict() for r in all_user_data()]
    return jsonify({'users': all_users})
def change_password(_admin_user):
    params = assert_data_has_keys(request, {'email', 'new_password'})
    user = User.from_db_row(user_data_by_email(params['email']))
    user.reset_password(params['new_password'])
    return jsonify({'message': 'ok'})
Beispiel #3
0
 def authenticate(cls, email, password):
     user = cls.from_db_row(db.user_data_by_email(email))
     if not bcrypt.checkpw(password.encode(), user.hashed_password):
         raise WebError("password incorrect", status_code=401)
     else:
         return user