Beispiel #1
0
def get_auth():
    r = validate_queries(['name','password'])
    result = db.key_store.get_auth(r['name'], r['password'])
    if result:
        return result
    else:
        response.status = "403 Login Failed"
        return json.dumps({'message': "Login Failed"})
Beispiel #2
0
def post_auth():
    r = validate_queries(['name','password'])
    result = db.key_store.post_auth(r['name'], r['password'])
    if result: # TODO: Should create a new User()
        return result
    else:
        response.status = "409 Username already in use."
        return json.dumps({'message': "Username already in use."})
Beispiel #3
0
def put_auth(name, authed):
    r = validate_queries(['password', 'newPassword'])
    if name == authed:
        result = db.key_store.put_auth(name, r['password'], r['newPassword'])
        if result:
            return result
        else:
            raise HTTPError(404, "Username not found.")
    else:
        raise HTTPError(403)