예제 #1
0
    public async Task <IActionResult> AddUserPermissionsToTenantByEmail(string tenantId, string userEmail, string[] permissions)
    {
        try
        {
            await _permissionsService.AddUserPermissionsToTenantByEmailAsync(tenantId, userEmail, permissions);

            return(Ok());
        }
        catch (ItemAlreadyExistsException ex)
        {
            _logger.LogError("Permissions where not able to be added to {userEmail} on {tenantId}. Permission already exists.", userEmail, tenantId);
            return(BadRequest(ex.Message));
        }
        catch (UserNotFoundException ex)
        {
            _logger.LogError("User: {userEmail} was not found in the identity provider or more than one user exists with that email. permissions could not be added on {tenantId}", userEmail, tenantId);
            return(BadRequest(ex.Message));
        }
    }