Exemplo n.º 1
0
def remove_permission(auth_user: AuthUser, username: str, company_id: str):
    if auth_user.username not in admin_list:
        return {'error': 'unauthorized'}

    cla.log.info('company ({}) removed for ({}) by {}'.format(
        company_id, username, auth_user.username))

    company = Company()
    try:
        company.load(company_id)
    except Exception as err:
        print('Unable to update company permission: {}'.format(err))
        return {'error': str(err)}

    company.remove_company_acl(username)
    event_data = 'company ({}) removed for ({}) by {}'.format(
        company_id, username, auth_user.username)
    Event.create_event(
        event_data=event_data,
        event_summary=event_data,
        event_company_id=company_id,
        event_type=EventType.RemoveCompanyPermission,
        contains_pii=True,
    )
    company.save()
Exemplo n.º 2
0
def remove_permission(auth_user: AuthUser, username: str, company_id: str):
    fn = 'controllers.company.remove_permission'
    if auth_user.username not in admin_list:
        return {'error': 'unauthorized'}

    cla.log.info(
        f'{fn} - company ({company_id}) removed for user ({username}) by {auth_user.username}'
    )

    company = Company()
    try:
        company.load(company_id)
    except Exception as err:
        cla.log.warning(f'{fn} - unable to update company permission: {err}')
        return {'error': str(err)}

    company.remove_company_acl(username)
    event_data = f'Removed user {username} from Company {company.get_company_name()} permissions list.'
    Event.create_event(
        event_data=event_data,
        event_summary=event_data,
        event_company_id=company_id,
        event_type=EventType.RemoveCompanyPermission,
        contains_pii=True,
    )
    company.save()
Exemplo n.º 3
0
def remove_permission(auth_user: AuthUser, username: str, company_id: str):
    if auth_user.username not in admin_list:
        return {'error': 'unauthorized'}

    cla.log.info('company ({}) removed for ({}) by {}'.format(company_id, username, auth_user.username))

    company = Company()
    try:
        company.load(company_id)
    except Exception as err:
        print('Unable to update company permission: {}'.format(err))
        return {'error': str(err)}

    company.remove_company_acl(username)
    company.save()