Exemple #1
0
def set_photo():
    params = assert_data_has_keys(request, {'email', 'password', 'patient_id'}, data_type='form')
    User.authenticate(params['email'], params['password'])
    if 'photo' not in request.files:
        raise WebError('photo must be provided', 400)
    base_filename = store_photo(request.files['photo'])
    set_patient_filename(params['patient_id'], base_filename)
    return jsonify({'message': 'ok'})
Exemple #2
0
def get_photo():
    params = assert_data_has_keys(request, {'email', 'password', 'patient_id'})
    User.authenticate(params['email'], params['password'])
    base_filename = photo_filename_by_patient(params['patient_id'])
    if base_filename is None:
        raise WebError('Patient photo unavailable', 404)
    filename = retrieve_photo(base_filename)
    if filename is None:
        raise WebError('Patient photo unavailable', 404)
    return send_file(filename)
Exemple #3
0
def sync():
    params = assert_data_has_keys(request, {'email', 'password'}, data_type='form')
    User.authenticate(params['email'], params['password'])
    if 'db' not in request.files:
        raise WebError('db must be provided', 400)

    synchronizer = DbSynchronizer(request.files['db'])
    if not synchronizer.prepare_sync():
        raise WebError("Synchronization failed", 500)

    synchronizer.execute_server_side_sql()
    return jsonify({'to_execute': synchronizer.get_client_sql()})
def loginUser():
    """
  Use the given username and password to either login the user or return an error
  """
    user, authenticated = User.authenticate(request.args['username'],
                                            request.args['password'])
    if user != None and authenticated:
        login_user(user)
        return "ok"
    else:
        return "-1"
def login():
    params = assert_data_has_keys(request, {'email', 'password'})
    user = User.authenticate(params['email'], params['password'])
    token = user.create_token()
    return jsonify({'token': token})
Exemple #6
0
def login():
    params = assert_data_has_keys(request, {'email', 'password'})
    user = User.authenticate(params['email'], params['password'])
    return jsonify(user.to_dict())
Exemple #7
0
def metadata():
    params = assert_data_has_keys(request, {'email', 'password'})
    User.authenticate(params['email'], params['password'])
    response = {k.replace('-', ''): v for k, v in all_photo_filenames()}
    return jsonify(response)
def sync():
    params = assert_data_has_keys(request,
                                  {'email', 'password', 'new_password'})
    user = User.authenticate(params['email'], params['password'])
    user.reset_password(params['new_password'])
    return jsonify({'message': 'OK'})