mirror of
https://github.com/bitwarden/server.git
synced 2025-04-06 21:48:12 -05:00
rename AccessAllCollections => AccessAll
This commit is contained in:
parent
8458022a58
commit
da03c276aa
@ -75,7 +75,7 @@ namespace Bit.Api.Controllers
|
|||||||
|
|
||||||
var userId = _userService.GetProperUserId(User);
|
var userId = _userService.GetProperUserId(User);
|
||||||
var result = await _organizationService.InviteUserAsync(orgGuidId, userId.Value, model.Email, model.Type.Value,
|
var result = await _organizationService.InviteUserAsync(orgGuidId, userId.Value, model.Email, model.Type.Value,
|
||||||
model.AccessAllCollections, model.Collections?.Select(c => c.ToCollectionUser()));
|
model.AccessAll, model.Collections?.Select(c => c.ToCollectionUser()));
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPut("{id}/reinvite")]
|
[HttpPut("{id}/reinvite")]
|
||||||
|
@ -12,7 +12,7 @@ namespace Bit.Core.Models.Api
|
|||||||
public string Email { get; set; }
|
public string Email { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public Enums.OrganizationUserType? Type { get; set; }
|
public Enums.OrganizationUserType? Type { get; set; }
|
||||||
public bool AccessAllCollections { get; set; }
|
public bool AccessAll { get; set; }
|
||||||
public IEnumerable<OrganizationUserCollectionRequestModel> Collections { get; set; }
|
public IEnumerable<OrganizationUserCollectionRequestModel> Collections { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,13 +32,13 @@ namespace Bit.Core.Models.Api
|
|||||||
{
|
{
|
||||||
[Required]
|
[Required]
|
||||||
public Enums.OrganizationUserType? Type { get; set; }
|
public Enums.OrganizationUserType? Type { get; set; }
|
||||||
public bool AccessAllCollections { get; set; }
|
public bool AccessAll { get; set; }
|
||||||
public IEnumerable<OrganizationUserCollectionRequestModel> Collections { get; set; }
|
public IEnumerable<OrganizationUserCollectionRequestModel> Collections { get; set; }
|
||||||
|
|
||||||
public OrganizationUser ToOrganizationUser(OrganizationUser existingUser)
|
public OrganizationUser ToOrganizationUser(OrganizationUser existingUser)
|
||||||
{
|
{
|
||||||
existingUser.Type = Type.Value;
|
existingUser.Type = Type.Value;
|
||||||
existingUser.AccessAllCollections = AccessAllCollections;
|
existingUser.AccessAll = AccessAll;
|
||||||
return existingUser;
|
return existingUser;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ namespace Bit.Core.Models.Api
|
|||||||
Id = collectionUser.Id?.ToString();
|
Id = collectionUser.Id?.ToString();
|
||||||
OrganizationUserId = collectionUser.OrganizationUserId.ToString();
|
OrganizationUserId = collectionUser.OrganizationUserId.ToString();
|
||||||
CollectionId = collectionUser.CollectionId?.ToString();
|
CollectionId = collectionUser.CollectionId?.ToString();
|
||||||
AccessAllCollections = collectionUser.AccessAllCollections;
|
AccessAll = collectionUser.AccessAll;
|
||||||
Name = collectionUser.Name;
|
Name = collectionUser.Name;
|
||||||
Email = collectionUser.Email;
|
Email = collectionUser.Email;
|
||||||
Type = collectionUser.Type;
|
Type = collectionUser.Type;
|
||||||
@ -29,7 +29,7 @@ namespace Bit.Core.Models.Api
|
|||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
public string OrganizationUserId { get; set; }
|
public string OrganizationUserId { get; set; }
|
||||||
public string CollectionId { get; set; }
|
public string CollectionId { get; set; }
|
||||||
public bool AccessAllCollections { get; set; }
|
public bool AccessAll { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string Email { get; set; }
|
public string Email { get; set; }
|
||||||
public OrganizationUserType Type { get; set; }
|
public OrganizationUserType Type { get; set; }
|
||||||
|
@ -22,7 +22,7 @@ namespace Bit.Core.Models.Api
|
|||||||
Email = organizationUser.Email;
|
Email = organizationUser.Email;
|
||||||
Type = organizationUser.Type;
|
Type = organizationUser.Type;
|
||||||
Status = organizationUser.Status;
|
Status = organizationUser.Status;
|
||||||
AccessAllCollections = organizationUser.AccessAllCollections;
|
AccessAll = organizationUser.AccessAll;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
@ -31,7 +31,7 @@ namespace Bit.Core.Models.Api
|
|||||||
public string Email { get; set; }
|
public string Email { get; set; }
|
||||||
public OrganizationUserType Type { get; set; }
|
public OrganizationUserType Type { get; set; }
|
||||||
public OrganizationUserStatusType Status { get; set; }
|
public OrganizationUserStatusType Status { get; set; }
|
||||||
public bool AccessAllCollections { get; set; }
|
public bool AccessAll { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class OrganizationUserDetailsResponseModel : OrganizationUserResponseModel
|
public class OrganizationUserDetailsResponseModel : OrganizationUserResponseModel
|
||||||
|
@ -7,7 +7,7 @@ namespace Bit.Core.Models.Data
|
|||||||
public Guid? Id { get; set; }
|
public Guid? Id { get; set; }
|
||||||
public Guid OrganizationUserId { get; set; }
|
public Guid OrganizationUserId { get; set; }
|
||||||
public Guid? CollectionId { get; set; }
|
public Guid? CollectionId { get; set; }
|
||||||
public bool AccessAllCollections { get; set; }
|
public bool AccessAll { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string Email { get; set; }
|
public string Email { get; set; }
|
||||||
public Enums.OrganizationUserStatusType Status { get; set; }
|
public Enums.OrganizationUserStatusType Status { get; set; }
|
||||||
|
@ -11,6 +11,6 @@ namespace Bit.Core.Models.Data
|
|||||||
public string Email { get; set; }
|
public string Email { get; set; }
|
||||||
public Enums.OrganizationUserStatusType Status { get; set; }
|
public Enums.OrganizationUserStatusType Status { get; set; }
|
||||||
public Enums.OrganizationUserType Type { get; set; }
|
public Enums.OrganizationUserType Type { get; set; }
|
||||||
public bool AccessAllCollections { get; set; }
|
public bool AccessAll { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ namespace Bit.Core.Models.Table
|
|||||||
public string Key { get; set; }
|
public string Key { get; set; }
|
||||||
public OrganizationUserStatusType Status { get; set; }
|
public OrganizationUserStatusType Status { get; set; }
|
||||||
public OrganizationUserType Type { get; set; }
|
public OrganizationUserType Type { get; set; }
|
||||||
public bool AccessAllCollections { get; set; }
|
public bool AccessAll { get; set; }
|
||||||
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
|
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
|
||||||
public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow;
|
public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow;
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ namespace Bit.Core.Services
|
|||||||
Task EnableAsync(Guid organizationId);
|
Task EnableAsync(Guid organizationId);
|
||||||
Task UpdateAsync(Organization organization, bool updateBilling = false);
|
Task UpdateAsync(Organization organization, bool updateBilling = false);
|
||||||
Task<OrganizationUser> InviteUserAsync(Guid organizationId, Guid invitingUserId, string email,
|
Task<OrganizationUser> InviteUserAsync(Guid organizationId, Guid invitingUserId, string email,
|
||||||
Enums.OrganizationUserType type, bool accessAllCollections, IEnumerable<CollectionUser> collections);
|
OrganizationUserType type, bool accessAll, IEnumerable<CollectionUser> collections);
|
||||||
Task ResendInviteAsync(Guid organizationId, Guid invitingUserId, Guid organizationUserId);
|
Task ResendInviteAsync(Guid organizationId, Guid invitingUserId, Guid organizationUserId);
|
||||||
Task<OrganizationUser> AcceptUserAsync(Guid organizationUserId, User user, string token);
|
Task<OrganizationUser> AcceptUserAsync(Guid organizationUserId, User user, string token);
|
||||||
Task<OrganizationUser> ConfirmUserAsync(Guid organizationId, Guid organizationUserId, string key, Guid confirmingUserId);
|
Task<OrganizationUser> ConfirmUserAsync(Guid organizationId, Guid organizationUserId, string key, Guid confirmingUserId);
|
||||||
|
@ -570,7 +570,7 @@ namespace Bit.Core.Services
|
|||||||
Key = signup.OwnerKey,
|
Key = signup.OwnerKey,
|
||||||
Type = OrganizationUserType.Owner,
|
Type = OrganizationUserType.Owner,
|
||||||
Status = OrganizationUserStatusType.Confirmed,
|
Status = OrganizationUserStatusType.Confirmed,
|
||||||
AccessAllCollections = true,
|
AccessAll = true,
|
||||||
CreationDate = DateTime.UtcNow,
|
CreationDate = DateTime.UtcNow,
|
||||||
RevisionDate = DateTime.UtcNow
|
RevisionDate = DateTime.UtcNow
|
||||||
};
|
};
|
||||||
@ -672,7 +672,7 @@ namespace Bit.Core.Services
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async Task<OrganizationUser> InviteUserAsync(Guid organizationId, Guid invitingUserId, string email,
|
public async Task<OrganizationUser> InviteUserAsync(Guid organizationId, Guid invitingUserId, string email,
|
||||||
OrganizationUserType type, bool accessAllCollections, IEnumerable<CollectionUser> collections)
|
OrganizationUserType type, bool accessAll, IEnumerable<CollectionUser> collections)
|
||||||
{
|
{
|
||||||
var organization = await _organizationRepository.GetByIdAsync(organizationId);
|
var organization = await _organizationRepository.GetByIdAsync(organizationId);
|
||||||
if(organization == null)
|
if(organization == null)
|
||||||
@ -705,13 +705,13 @@ namespace Bit.Core.Services
|
|||||||
Key = null,
|
Key = null,
|
||||||
Type = type,
|
Type = type,
|
||||||
Status = OrganizationUserStatusType.Invited,
|
Status = OrganizationUserStatusType.Invited,
|
||||||
AccessAllCollections = accessAllCollections,
|
AccessAll = accessAll,
|
||||||
CreationDate = DateTime.UtcNow,
|
CreationDate = DateTime.UtcNow,
|
||||||
RevisionDate = DateTime.UtcNow
|
RevisionDate = DateTime.UtcNow
|
||||||
};
|
};
|
||||||
|
|
||||||
await _organizationUserRepository.CreateAsync(orgUser);
|
await _organizationUserRepository.CreateAsync(orgUser);
|
||||||
if(!orgUser.AccessAllCollections && collections.Any())
|
if(!orgUser.AccessAll && collections.Any())
|
||||||
{
|
{
|
||||||
await SaveUserCollectionsAsync(orgUser, collections, true);
|
await SaveUserCollectionsAsync(orgUser, collections, true);
|
||||||
}
|
}
|
||||||
@ -835,7 +835,7 @@ namespace Bit.Core.Services
|
|||||||
|
|
||||||
await _organizationUserRepository.ReplaceAsync(user);
|
await _organizationUserRepository.ReplaceAsync(user);
|
||||||
|
|
||||||
if(user.AccessAllCollections)
|
if(user.AccessAll)
|
||||||
{
|
{
|
||||||
// We don't need any collections if we're flagged to have all access.
|
// We don't need any collections if we're flagged to have all access.
|
||||||
collections = new List<CollectionUser>();
|
collections = new List<CollectionUser>();
|
||||||
|
@ -5,7 +5,7 @@ BEGIN
|
|||||||
|
|
||||||
;WITH [CTE] AS(
|
;WITH [CTE] AS(
|
||||||
SELECT
|
SELECT
|
||||||
CASE WHEN OU.[AccessAllCollections] = 1 OR CU.[ReadOnly] = 0 THEN 1 ELSE 0 END [CanEdit]
|
CASE WHEN OU.[AccessAll] = 1 OR CU.[ReadOnly] = 0 THEN 1 ELSE 0 END [CanEdit]
|
||||||
FROM
|
FROM
|
||||||
[dbo].[Cipher] C
|
[dbo].[Cipher] C
|
||||||
INNER JOIN
|
INNER JOIN
|
||||||
@ -13,14 +13,14 @@ BEGIN
|
|||||||
INNER JOIN
|
INNER JOIN
|
||||||
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
|
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
[dbo].[CollectionCipher] CC ON C.[UserId] IS NULL AND OU.[AccessAllCollections] = 0 AND CC.[CipherId] = C.[Id]
|
[dbo].[CollectionCipher] CC ON C.[UserId] IS NULL AND OU.[AccessAll] = 0 AND CC.[CipherId] = C.[Id]
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
[dbo].[CollectionUser] CU ON CU.[CollectionId] = CC.[CollectionId] AND CU.[OrganizationUserId] = OU.[Id]
|
[dbo].[CollectionUser] CU ON CU.[CollectionId] = CC.[CollectionId] AND CU.[OrganizationUserId] = OU.[Id]
|
||||||
WHERE
|
WHERE
|
||||||
C.[Id] = @CipherId
|
C.[Id] = @CipherId
|
||||||
AND OU.[Status] = 2 -- 2 = Confirmed
|
AND OU.[Status] = 2 -- 2 = Confirmed
|
||||||
AND O.[Enabled] = 1
|
AND O.[Enabled] = 1
|
||||||
AND (OU.[AccessAllCollections] = 1 OR CU.[CollectionId] IS NOT NULL)
|
AND (OU.[AccessAll] = 1 OR CU.[CollectionId] IS NOT NULL)
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
@CanEdit = CASE WHEN COUNT(1) > 0 THEN 1 ELSE 0 END
|
@CanEdit = CASE WHEN COUNT(1) > 0 THEN 1 ELSE 0 END
|
||||||
|
@ -14,7 +14,7 @@ BEGIN
|
|||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
|
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
[dbo].[CollectionCipher] CC ON C.[UserId] IS NULL AND OU.[AccessAllCollections] = 0 AND CC.[CipherId] = C.[Id]
|
[dbo].[CollectionCipher] CC ON C.[UserId] IS NULL AND OU.[AccessAll] = 0 AND CC.[CipherId] = C.[Id]
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
[dbo].[CollectionUser] CU ON CU.[CollectionId] = CC.[CollectionId] AND CU.[OrganizationUserId] = OU.[Id]
|
[dbo].[CollectionUser] CU ON CU.[CollectionId] = CC.[CollectionId] AND CU.[OrganizationUserId] = OU.[Id]
|
||||||
WHERE
|
WHERE
|
||||||
@ -25,7 +25,7 @@ BEGIN
|
|||||||
C.[UserId] IS NULL
|
C.[UserId] IS NULL
|
||||||
AND OU.[Status] = 2 -- 2 = Confirmed
|
AND OU.[Status] = 2 -- 2 = Confirmed
|
||||||
AND O.[Enabled] = 1
|
AND O.[Enabled] = 1
|
||||||
AND (OU.[AccessAllCollections] = 1 OR CU.[CollectionId] IS NOT NULL)
|
AND (OU.[AccessAll] = 1 OR CU.[CollectionId] IS NOT NULL)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
END
|
END
|
@ -14,7 +14,7 @@ BEGIN
|
|||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
|
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
[dbo].[CollectionCipher] CC ON C.[UserId] IS NULL AND OU.[AccessAllCollections] = 0 AND CC.[CipherId] = C.[Id]
|
[dbo].[CollectionCipher] CC ON C.[UserId] IS NULL AND OU.[AccessAll] = 0 AND CC.[CipherId] = C.[Id]
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
[dbo].[CollectionUser] CU ON CU.[CollectionId] = CC.[CollectionId] AND CU.[OrganizationUserId] = OU.[Id]
|
[dbo].[CollectionUser] CU ON CU.[CollectionId] = CC.[CollectionId] AND CU.[OrganizationUserId] = OU.[Id]
|
||||||
WHERE
|
WHERE
|
||||||
@ -25,7 +25,7 @@ BEGIN
|
|||||||
C.[UserId] IS NULL
|
C.[UserId] IS NULL
|
||||||
AND OU.[Status] = 2 -- 2 = Confirmed
|
AND OU.[Status] = 2 -- 2 = Confirmed
|
||||||
AND O.[Enabled] = 1
|
AND O.[Enabled] = 1
|
||||||
AND (OU.[AccessAllCollections] = 1 OR CU.[CollectionId] IS NOT NULL)
|
AND (OU.[AccessAll] = 1 OR CU.[CollectionId] IS NOT NULL)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
END
|
END
|
@ -13,7 +13,7 @@ BEGIN
|
|||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
|
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
[dbo].[CollectionCipher] CC ON C.[UserId] IS NULL AND OU.[AccessAllCollections] = 0 AND CC.[CipherId] = C.[Id]
|
[dbo].[CollectionCipher] CC ON C.[UserId] IS NULL AND OU.[AccessAll] = 0 AND CC.[CipherId] = C.[Id]
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
[dbo].[CollectionUser] CU ON CU.[CollectionId] = CC.[CollectionId] AND CU.[OrganizationUserId] = OU.[Id]
|
[dbo].[CollectionUser] CU ON CU.[CollectionId] = CC.[CollectionId] AND CU.[OrganizationUserId] = OU.[Id]
|
||||||
WHERE
|
WHERE
|
||||||
@ -22,6 +22,6 @@ BEGIN
|
|||||||
C.[UserId] IS NULL
|
C.[UserId] IS NULL
|
||||||
AND OU.[Status] = 2 -- 2 = Confirmed
|
AND OU.[Status] = 2 -- 2 = Confirmed
|
||||||
AND O.[Enabled] = 1
|
AND O.[Enabled] = 1
|
||||||
AND (OU.[AccessAllCollections] = 1 OR CU.[CollectionId] IS NOT NULL)
|
AND (OU.[AccessAll] = 1 OR CU.[CollectionId] IS NOT NULL)
|
||||||
)
|
)
|
||||||
END
|
END
|
@ -13,11 +13,11 @@ BEGIN
|
|||||||
INNER JOIN
|
INNER JOIN
|
||||||
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
|
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
[dbo].[CollectionCipher] CC ON C.[UserId] IS NULL AND OU.[AccessAllCollections] = 0 AND CC.[CipherId] = C.[Id]
|
[dbo].[CollectionCipher] CC ON C.[UserId] IS NULL AND OU.[AccessAll] = 0 AND CC.[CipherId] = C.[Id]
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
[dbo].[CollectionUser] CU ON CU.[CollectionId] = CC.[CollectionId] AND CU.[OrganizationUserId] = OU.[Id]
|
[dbo].[CollectionUser] CU ON CU.[CollectionId] = CC.[CollectionId] AND CU.[OrganizationUserId] = OU.[Id]
|
||||||
WHERE
|
WHERE
|
||||||
OU.[Status] = 2 -- 2 = Confirmed
|
OU.[Status] = 2 -- 2 = Confirmed
|
||||||
AND O.[Enabled] = 1
|
AND O.[Enabled] = 1
|
||||||
AND (OU.[AccessAllCollections] = 1 OR CU.[CollectionId] IS NOT NULL)
|
AND (OU.[AccessAll] = 1 OR CU.[CollectionId] IS NOT NULL)
|
||||||
END
|
END
|
@ -18,7 +18,7 @@ BEGIN
|
|||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
|
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
[dbo].[CollectionCipher] CC ON C.[UserId] IS NULL AND OU.[AccessAllCollections] = 0 AND CC.[CipherId] = C.[Id]
|
[dbo].[CollectionCipher] CC ON C.[UserId] IS NULL AND OU.[AccessAll] = 0 AND CC.[CipherId] = C.[Id]
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
[dbo].[CollectionUser] CU ON CU.[CollectionId] = CC.[CollectionId] AND CU.[OrganizationUserId] = OU.[Id]
|
[dbo].[CollectionUser] CU ON CU.[CollectionId] = CC.[CollectionId] AND CU.[OrganizationUserId] = OU.[Id]
|
||||||
WHERE
|
WHERE
|
||||||
@ -29,7 +29,7 @@ BEGIN
|
|||||||
C.[UserId] IS NULL
|
C.[UserId] IS NULL
|
||||||
AND OU.[Status] = 2 -- 2 = Confirmed
|
AND OU.[Status] = 2 -- 2 = Confirmed
|
||||||
AND O.[Enabled] = 1
|
AND O.[Enabled] = 1
|
||||||
AND (OU.[AccessAllCollections] = 1 OR CU.[CollectionId] IS NOT NULL)
|
AND (OU.[AccessAll] = 1 OR CU.[CollectionId] IS NOT NULL)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
END
|
END
|
@ -34,12 +34,12 @@ BEGIN
|
|||||||
INNER JOIN
|
INNER JOIN
|
||||||
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
|
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
[dbo].[CollectionUser] CU ON OU.[AccessAllCollections] = 0 AND CU.[CollectionId] = S.[Id] AND CU.[OrganizationUserId] = OU.[Id]
|
[dbo].[CollectionUser] CU ON OU.[AccessAll] = 0 AND CU.[CollectionId] = S.[Id] AND CU.[OrganizationUserId] = OU.[Id]
|
||||||
WHERE
|
WHERE
|
||||||
O.[Id] = @OrganizationId
|
O.[Id] = @OrganizationId
|
||||||
AND O.[Enabled] = 1
|
AND O.[Enabled] = 1
|
||||||
AND OU.[Status] = 2 -- Confirmed
|
AND OU.[Status] = 2 -- Confirmed
|
||||||
AND (OU.[AccessAllCollections] = 1 OR CU.[ReadOnly] = 0)
|
AND (OU.[AccessAll] = 1 OR CU.[ReadOnly] = 0)
|
||||||
)
|
)
|
||||||
INSERT INTO [dbo].[CollectionCipher]
|
INSERT INTO [dbo].[CollectionCipher]
|
||||||
(
|
(
|
||||||
|
@ -13,8 +13,8 @@ BEGIN
|
|||||||
INNER JOIN
|
INNER JOIN
|
||||||
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = S.[OrganizationId] AND OU.[UserId] = @UserId
|
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = S.[OrganizationId] AND OU.[UserId] = @UserId
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
[dbo].[CollectionUser] CU ON OU.[AccessAllCollections] = 0 AND CU.[CollectionId] = S.[Id] AND CU.[OrganizationUserId] = OU.[Id]
|
[dbo].[CollectionUser] CU ON OU.[AccessAll] = 0 AND CU.[CollectionId] = S.[Id] AND CU.[OrganizationUserId] = OU.[Id]
|
||||||
WHERE
|
WHERE
|
||||||
OU.[Status] = 2 -- Confirmed
|
OU.[Status] = 2 -- Confirmed
|
||||||
AND (OU.[AccessAllCollections] = 1 OR CU.[CollectionId] IS NOT NULL)
|
AND (OU.[AccessAll] = 1 OR CU.[CollectionId] IS NOT NULL)
|
||||||
END
|
END
|
@ -14,9 +14,9 @@ BEGIN
|
|||||||
INNER JOIN
|
INNER JOIN
|
||||||
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = S.[OrganizationId] AND OU.[UserId] = @UserId
|
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = S.[OrganizationId] AND OU.[UserId] = @UserId
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
[dbo].[CollectionUser] CU ON OU.[AccessAllCollections] = 0 AND CU.[CollectionId] = S.[Id] AND CU.[OrganizationUserId] = OU.[Id]
|
[dbo].[CollectionUser] CU ON OU.[AccessAll] = 0 AND CU.[CollectionId] = S.[Id] AND CU.[OrganizationUserId] = OU.[Id]
|
||||||
WHERE
|
WHERE
|
||||||
SC.[CipherId] = @CipherId
|
SC.[CipherId] = @CipherId
|
||||||
AND OU.[Status] = 2 -- Confirmed
|
AND OU.[Status] = 2 -- Confirmed
|
||||||
AND (OU.[AccessAllCollections] = 1 OR CU.[CollectionId] IS NOT NULL)
|
AND (OU.[AccessAll] = 1 OR CU.[CollectionId] IS NOT NULL)
|
||||||
END
|
END
|
@ -25,12 +25,12 @@ BEGIN
|
|||||||
INNER JOIN
|
INNER JOIN
|
||||||
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
|
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
[dbo].[CollectionUser] CU ON OU.[AccessAllCollections] = 0 AND CU.[CollectionId] = S.[Id] AND CU.[OrganizationUserId] = OU.[Id]
|
[dbo].[CollectionUser] CU ON OU.[AccessAll] = 0 AND CU.[CollectionId] = S.[Id] AND CU.[OrganizationUserId] = OU.[Id]
|
||||||
WHERE
|
WHERE
|
||||||
O.[Id] = @OrgId
|
O.[Id] = @OrgId
|
||||||
AND O.[Enabled] = 1
|
AND O.[Enabled] = 1
|
||||||
AND OU.[Status] = 2 -- Confirmed
|
AND OU.[Status] = 2 -- Confirmed
|
||||||
AND (OU.[AccessAllCollections] = 1 OR CU.[ReadOnly] = 0)
|
AND (OU.[AccessAll] = 1 OR CU.[ReadOnly] = 0)
|
||||||
)
|
)
|
||||||
MERGE
|
MERGE
|
||||||
[dbo].[CollectionCipher] AS [Target]
|
[dbo].[CollectionCipher] AS [Target]
|
||||||
|
@ -9,6 +9,6 @@ BEGIN
|
|||||||
FROM
|
FROM
|
||||||
[dbo].[CollectionUserUserDetailsView]
|
[dbo].[CollectionUserUserDetailsView]
|
||||||
WHERE
|
WHERE
|
||||||
[AccessAllCollections] = 1
|
[AccessAll] = 1
|
||||||
OR [CollectionId] = @CollectionId
|
OR [CollectionId] = @CollectionId
|
||||||
END
|
END
|
@ -13,9 +13,9 @@ BEGIN
|
|||||||
INNER JOIN
|
INNER JOIN
|
||||||
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
|
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
[dbo].[CollectionUser] CU ON OU.[AccessAllCollections] = 0 AND CU.[CollectionId] = S.[Id] AND CU.[OrganizationUserId] = OU.[Id]
|
[dbo].[CollectionUser] CU ON OU.[AccessAll] = 0 AND CU.[CollectionId] = S.[Id] AND CU.[OrganizationUserId] = OU.[Id]
|
||||||
WHERE
|
WHERE
|
||||||
OU.[Status] = 2 -- Confirmed
|
OU.[Status] = 2 -- Confirmed
|
||||||
AND O.[Enabled] = 1
|
AND O.[Enabled] = 1
|
||||||
AND (OU.[AccessAllCollections] = 1 OR CU.[CollectionId] IS NOT NULL)
|
AND (OU.[AccessAll] = 1 OR CU.[CollectionId] IS NOT NULL)
|
||||||
END
|
END
|
@ -18,14 +18,14 @@ BEGIN
|
|||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
|
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
[dbo].[CollectionCipher] CC ON C.[UserId] IS NULL AND OU.[AccessAllCollections] = 0 AND CC.[CipherId] = C.[Id]
|
[dbo].[CollectionCipher] CC ON C.[UserId] IS NULL AND OU.[AccessAll] = 0 AND CC.[CipherId] = C.[Id]
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
[dbo].[CollectionUser] CU ON CU.[CollectionId] = CC.[CollectionId] AND CU.[OrganizationUserId] = OU.[Id]
|
[dbo].[CollectionUser] CU ON CU.[CollectionId] = CC.[CollectionId] AND CU.[OrganizationUserId] = OU.[Id]
|
||||||
WHERE
|
WHERE
|
||||||
C.[UserId] = @UserId
|
C.[UserId] = @UserId
|
||||||
OR (
|
OR (
|
||||||
C.[UserId] IS NULL
|
C.[UserId] IS NULL
|
||||||
AND (OU.[AccessAllCollections] = 1 OR CU.[CollectionId] IS NOT NULL)
|
AND (OU.[AccessAll] = 1 OR CU.[CollectionId] IS NOT NULL)
|
||||||
)
|
)
|
||||||
AND C.[Folders] IS NOT NULL
|
AND C.[Folders] IS NOT NULL
|
||||||
AND JSON_VALUE(C.[Folders], @UserIdPath) = @Id
|
AND JSON_VALUE(C.[Folders], @UserIdPath) = @Id
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
@Key VARCHAR(MAX),
|
@Key VARCHAR(MAX),
|
||||||
@Status TINYINT,
|
@Status TINYINT,
|
||||||
@Type TINYINT,
|
@Type TINYINT,
|
||||||
@AccessAllCollections BIT,
|
@AccessAll BIT,
|
||||||
@CreationDate DATETIME2(7),
|
@CreationDate DATETIME2(7),
|
||||||
@RevisionDate DATETIME2(7)
|
@RevisionDate DATETIME2(7)
|
||||||
AS
|
AS
|
||||||
@ -22,7 +22,7 @@ BEGIN
|
|||||||
[Key],
|
[Key],
|
||||||
[Status],
|
[Status],
|
||||||
[Type],
|
[Type],
|
||||||
[AccessAllCollections],
|
[AccessAll],
|
||||||
[CreationDate],
|
[CreationDate],
|
||||||
[RevisionDate]
|
[RevisionDate]
|
||||||
)
|
)
|
||||||
@ -35,7 +35,7 @@ BEGIN
|
|||||||
@Key,
|
@Key,
|
||||||
@Status,
|
@Status,
|
||||||
@Type,
|
@Type,
|
||||||
@AccessAllCollections,
|
@AccessAll,
|
||||||
@CreationDate,
|
@CreationDate,
|
||||||
@RevisionDate
|
@RevisionDate
|
||||||
)
|
)
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
@Key VARCHAR(MAX),
|
@Key VARCHAR(MAX),
|
||||||
@Status TINYINT,
|
@Status TINYINT,
|
||||||
@Type TINYINT,
|
@Type TINYINT,
|
||||||
@AccessAllCollections BIT,
|
@AccessAll BIT,
|
||||||
@CreationDate DATETIME2(7),
|
@CreationDate DATETIME2(7),
|
||||||
@RevisionDate DATETIME2(7)
|
@RevisionDate DATETIME2(7)
|
||||||
AS
|
AS
|
||||||
@ -22,7 +22,7 @@ BEGIN
|
|||||||
[Key] = @Key,
|
[Key] = @Key,
|
||||||
[Status] = @Status,
|
[Status] = @Status,
|
||||||
[Type] = @Type,
|
[Type] = @Type,
|
||||||
[AccessAllCollections] = @AccessAllCollections,
|
[AccessAll] = @AccessAll,
|
||||||
[CreationDate] = @CreationDate,
|
[CreationDate] = @CreationDate,
|
||||||
[RevisionDate] = @RevisionDate
|
[RevisionDate] = @RevisionDate
|
||||||
WHERE
|
WHERE
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
[Key] VARCHAR (MAX) NULL,
|
[Key] VARCHAR (MAX) NULL,
|
||||||
[Status] TINYINT NOT NULL,
|
[Status] TINYINT NOT NULL,
|
||||||
[Type] TINYINT NOT NULL,
|
[Type] TINYINT NOT NULL,
|
||||||
[AccessAllCollections] BIT NOT NULL,
|
[AccessAll] BIT NOT NULL,
|
||||||
[CreationDate] DATETIME2 (7) NOT NULL,
|
[CreationDate] DATETIME2 (7) NOT NULL,
|
||||||
[RevisionDate] DATETIME2 (7) NOT NULL,
|
[RevisionDate] DATETIME2 (7) NOT NULL,
|
||||||
CONSTRAINT [PK_OrganizationUser] PRIMARY KEY CLUSTERED ([Id] ASC),
|
CONSTRAINT [PK_OrganizationUser] PRIMARY KEY CLUSTERED ([Id] ASC),
|
||||||
|
@ -2,17 +2,17 @@
|
|||||||
AS
|
AS
|
||||||
SELECT
|
SELECT
|
||||||
OU.[Id] AS [OrganizationUserId],
|
OU.[Id] AS [OrganizationUserId],
|
||||||
OU.[AccessAllCollections],
|
OU.[AccessAll],
|
||||||
CU.[Id],
|
CU.[Id],
|
||||||
CU.[CollectionId],
|
CU.[CollectionId],
|
||||||
U.[Name],
|
U.[Name],
|
||||||
ISNULL(U.[Email], OU.[Email]) Email,
|
ISNULL(U.[Email], OU.[Email]) Email,
|
||||||
OU.[Status],
|
OU.[Status],
|
||||||
OU.[Type],
|
OU.[Type],
|
||||||
CASE WHEN OU.[AccessAllCollections] = 0 AND CU.[ReadOnly] = 1 THEN 1 ELSE 0 END [ReadOnly]
|
CASE WHEN OU.[AccessAll] = 0 AND CU.[ReadOnly] = 1 THEN 1 ELSE 0 END [ReadOnly]
|
||||||
FROM
|
FROM
|
||||||
[dbo].[OrganizationUser] OU
|
[dbo].[OrganizationUser] OU
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
[dbo].[CollectionUser] CU ON OU.[AccessAllCollections] = 0 AND CU.[OrganizationUserId] = OU.[Id]
|
[dbo].[CollectionUser] CU ON OU.[AccessAll] = 0 AND CU.[OrganizationUserId] = OU.[Id]
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
[dbo].[User] U ON U.[Id] = OU.[UserId]
|
[dbo].[User] U ON U.[Id] = OU.[UserId]
|
@ -8,7 +8,7 @@ SELECT
|
|||||||
ISNULL(U.[Email], OU.[Email]) Email,
|
ISNULL(U.[Email], OU.[Email]) Email,
|
||||||
OU.[Status],
|
OU.[Status],
|
||||||
OU.[Type],
|
OU.[Type],
|
||||||
OU.[AccessAllCollections]
|
OU.[AccessAll]
|
||||||
FROM
|
FROM
|
||||||
[dbo].[OrganizationUser] OU
|
[dbo].[OrganizationUser] OU
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
|
Loading…
x
Reference in New Issue
Block a user