Esempio n. 1
0
def drop_invite(code):
    """Refuse to accept invite"""
    invite, user = _invite_and_user(code)
    try:
        user.delete()
    except osc_exc.NotFound:
        abort(404)

    InvitesDAO.complete_for_user(invite.user_id)
    return make_json_response(None, status_code=204)
Esempio n. 2
0
def drop_invite(code):
    """Refuse to accept invite"""
    invite, user = _invite_and_user(code)
    try:
        user.delete()
    except osc_exc.NotFound:
        abort(404)

    InvitesDAO.complete_for_user(invite.user_id)
    return make_json_response(None, status_code=204)
Esempio n. 3
0
def accept_invite(code):
    data = parse_request_data(_ACCEPT_SCHEMA, _ACCEPT_REQUIRES)
    invite, user = _invite_and_user(code)

    data['enabled'] = True
    try:
        update_user_data(user, data)
        user = auth.admin_client_set().identity_admin.users.get(user.id)
    except osc_exc.NotFound:
        abort(404)

    InvitesDAO.complete_for_user(user.id)
    return make_json_response(user_to_view(user, invite), 200)
Esempio n. 4
0
def accept_invite(code):
    data = parse_request_data(_ACCEPT_SCHEMA, _ACCEPT_REQUIRES)
    invite, user = _invite_and_user(code)

    data['enabled'] = True
    try:
        update_user_data(user, data)
        user = auth.admin_client_set().identity_admin.users.get(user.id)
    except osc_exc.NotFound:
        abort(404)

    InvitesDAO.complete_for_user(user.id)
    return make_json_response(user_to_view(user, invite), 200)
Esempio n. 5
0
def _invite_and_user(code):
    user_mgr = auth.admin_client_set().identity_admin.users
    invite = InvitesDAO.get(code)
    try:
        assert not invite.complete
        user = user_mgr.get(invite.user_id)
        assert not user.enabled
    except (osc_exc.NotFound, AssertionError):
        abort(404)
    return invite, user
Esempio n. 6
0
def _invite_and_user(code):
    user_mgr = auth.admin_client_set().identity_admin.users
    invite = InvitesDAO.get(code)
    try:
        assert not invite.complete
        user = user_mgr.get(invite.user_id)
        assert not user.enabled
    except (osc_exc.NotFound, AssertionError):
        abort(404)
    return invite, user