1
0
mirror of https://github.com/bitwarden/server.git synced 2025-02-17 02:01:53 +01:00

rename AccessAllCollections => AccessAll

This commit is contained in:
Kyle Spearrin 2017-04-27 15:35:26 -04:00
parent 8458022a58
commit da03c276aa
27 changed files with 53 additions and 53 deletions

View File

@ -75,7 +75,7 @@ namespace Bit.Api.Controllers
var userId = _userService.GetProperUserId(User);
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")]

View File

@ -12,7 +12,7 @@ namespace Bit.Core.Models.Api
public string Email { get; set; }
[Required]
public Enums.OrganizationUserType? Type { get; set; }
public bool AccessAllCollections { get; set; }
public bool AccessAll { get; set; }
public IEnumerable<OrganizationUserCollectionRequestModel> Collections { get; set; }
}
@ -32,13 +32,13 @@ namespace Bit.Core.Models.Api
{
[Required]
public Enums.OrganizationUserType? Type { get; set; }
public bool AccessAllCollections { get; set; }
public bool AccessAll { get; set; }
public IEnumerable<OrganizationUserCollectionRequestModel> Collections { get; set; }
public OrganizationUser ToOrganizationUser(OrganizationUser existingUser)
{
existingUser.Type = Type.Value;
existingUser.AccessAllCollections = AccessAllCollections;
existingUser.AccessAll = AccessAll;
return existingUser;
}
}

View File

@ -18,7 +18,7 @@ namespace Bit.Core.Models.Api
Id = collectionUser.Id?.ToString();
OrganizationUserId = collectionUser.OrganizationUserId.ToString();
CollectionId = collectionUser.CollectionId?.ToString();
AccessAllCollections = collectionUser.AccessAllCollections;
AccessAll = collectionUser.AccessAll;
Name = collectionUser.Name;
Email = collectionUser.Email;
Type = collectionUser.Type;
@ -29,7 +29,7 @@ namespace Bit.Core.Models.Api
public string Id { get; set; }
public string OrganizationUserId { get; set; }
public string CollectionId { get; set; }
public bool AccessAllCollections { get; set; }
public bool AccessAll { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public OrganizationUserType Type { get; set; }

View File

@ -22,7 +22,7 @@ namespace Bit.Core.Models.Api
Email = organizationUser.Email;
Type = organizationUser.Type;
Status = organizationUser.Status;
AccessAllCollections = organizationUser.AccessAllCollections;
AccessAll = organizationUser.AccessAll;
}
public string Id { get; set; }
@ -31,7 +31,7 @@ namespace Bit.Core.Models.Api
public string Email { get; set; }
public OrganizationUserType Type { get; set; }
public OrganizationUserStatusType Status { get; set; }
public bool AccessAllCollections { get; set; }
public bool AccessAll { get; set; }
}
public class OrganizationUserDetailsResponseModel : OrganizationUserResponseModel

View File

@ -7,7 +7,7 @@ namespace Bit.Core.Models.Data
public Guid? Id { get; set; }
public Guid OrganizationUserId { get; set; }
public Guid? CollectionId { get; set; }
public bool AccessAllCollections { get; set; }
public bool AccessAll { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public Enums.OrganizationUserStatusType Status { get; set; }

View File

@ -11,6 +11,6 @@ namespace Bit.Core.Models.Data
public string Email { get; set; }
public Enums.OrganizationUserStatusType Status { get; set; }
public Enums.OrganizationUserType Type { get; set; }
public bool AccessAllCollections { get; set; }
public bool AccessAll { get; set; }
}
}

View File

@ -13,7 +13,7 @@ namespace Bit.Core.Models.Table
public string Key { get; set; }
public OrganizationUserStatusType Status { 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 RevisionDate { get; internal set; } = DateTime.UtcNow;

View File

@ -21,7 +21,7 @@ namespace Bit.Core.Services
Task EnableAsync(Guid organizationId);
Task UpdateAsync(Organization organization, bool updateBilling = false);
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<OrganizationUser> AcceptUserAsync(Guid organizationUserId, User user, string token);
Task<OrganizationUser> ConfirmUserAsync(Guid organizationId, Guid organizationUserId, string key, Guid confirmingUserId);

View File

@ -570,7 +570,7 @@ namespace Bit.Core.Services
Key = signup.OwnerKey,
Type = OrganizationUserType.Owner,
Status = OrganizationUserStatusType.Confirmed,
AccessAllCollections = true,
AccessAll = true,
CreationDate = DateTime.UtcNow,
RevisionDate = DateTime.UtcNow
};
@ -672,7 +672,7 @@ namespace Bit.Core.Services
}
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);
if(organization == null)
@ -705,13 +705,13 @@ namespace Bit.Core.Services
Key = null,
Type = type,
Status = OrganizationUserStatusType.Invited,
AccessAllCollections = accessAllCollections,
AccessAll = accessAll,
CreationDate = DateTime.UtcNow,
RevisionDate = DateTime.UtcNow
};
await _organizationUserRepository.CreateAsync(orgUser);
if(!orgUser.AccessAllCollections && collections.Any())
if(!orgUser.AccessAll && collections.Any())
{
await SaveUserCollectionsAsync(orgUser, collections, true);
}
@ -835,7 +835,7 @@ namespace Bit.Core.Services
await _organizationUserRepository.ReplaceAsync(user);
if(user.AccessAllCollections)
if(user.AccessAll)
{
// We don't need any collections if we're flagged to have all access.
collections = new List<CollectionUser>();

View File

@ -5,7 +5,7 @@ BEGIN
;WITH [CTE] AS(
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
[dbo].[Cipher] C
INNER JOIN
@ -13,14 +13,14 @@ BEGIN
INNER JOIN
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
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
[dbo].[CollectionUser] CU ON CU.[CollectionId] = CC.[CollectionId] AND CU.[OrganizationUserId] = OU.[Id]
WHERE
C.[Id] = @CipherId
AND OU.[Status] = 2 -- 2 = Confirmed
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
@CanEdit = CASE WHEN COUNT(1) > 0 THEN 1 ELSE 0 END

View File

@ -14,7 +14,7 @@ BEGIN
LEFT JOIN
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
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
[dbo].[CollectionUser] CU ON CU.[CollectionId] = CC.[CollectionId] AND CU.[OrganizationUserId] = OU.[Id]
WHERE
@ -25,7 +25,7 @@ BEGIN
C.[UserId] IS NULL
AND OU.[Status] = 2 -- 2 = Confirmed
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

View File

@ -14,7 +14,7 @@ BEGIN
LEFT JOIN
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
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
[dbo].[CollectionUser] CU ON CU.[CollectionId] = CC.[CollectionId] AND CU.[OrganizationUserId] = OU.[Id]
WHERE
@ -25,7 +25,7 @@ BEGIN
C.[UserId] IS NULL
AND OU.[Status] = 2 -- 2 = Confirmed
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

View File

@ -13,7 +13,7 @@ BEGIN
LEFT JOIN
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
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
[dbo].[CollectionUser] CU ON CU.[CollectionId] = CC.[CollectionId] AND CU.[OrganizationUserId] = OU.[Id]
WHERE
@ -22,6 +22,6 @@ BEGIN
C.[UserId] IS NULL
AND OU.[Status] = 2 -- 2 = Confirmed
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

View File

@ -13,11 +13,11 @@ BEGIN
INNER JOIN
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
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
[dbo].[CollectionUser] CU ON CU.[CollectionId] = CC.[CollectionId] AND CU.[OrganizationUserId] = OU.[Id]
WHERE
OU.[Status] = 2 -- 2 = Confirmed
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

View File

@ -18,7 +18,7 @@ BEGIN
LEFT JOIN
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
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
[dbo].[CollectionUser] CU ON CU.[CollectionId] = CC.[CollectionId] AND CU.[OrganizationUserId] = OU.[Id]
WHERE
@ -29,7 +29,7 @@ BEGIN
C.[UserId] IS NULL
AND OU.[Status] = 2 -- 2 = Confirmed
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

View File

@ -34,12 +34,12 @@ BEGIN
INNER JOIN
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
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
O.[Id] = @OrganizationId
AND O.[Enabled] = 1
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]
(

View File

@ -13,8 +13,8 @@ BEGIN
INNER JOIN
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = S.[OrganizationId] AND OU.[UserId] = @UserId
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
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

View File

@ -14,9 +14,9 @@ BEGIN
INNER JOIN
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = S.[OrganizationId] AND OU.[UserId] = @UserId
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
SC.[CipherId] = @CipherId
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

View File

@ -25,12 +25,12 @@ BEGIN
INNER JOIN
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
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
O.[Id] = @OrgId
AND O.[Enabled] = 1
AND OU.[Status] = 2 -- Confirmed
AND (OU.[AccessAllCollections] = 1 OR CU.[ReadOnly] = 0)
AND (OU.[AccessAll] = 1 OR CU.[ReadOnly] = 0)
)
MERGE
[dbo].[CollectionCipher] AS [Target]

View File

@ -9,6 +9,6 @@ BEGIN
FROM
[dbo].[CollectionUserUserDetailsView]
WHERE
[AccessAllCollections] = 1
[AccessAll] = 1
OR [CollectionId] = @CollectionId
END

View File

@ -13,9 +13,9 @@ BEGIN
INNER JOIN
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
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
OU.[Status] = 2 -- Confirmed
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

View File

@ -18,14 +18,14 @@ BEGIN
LEFT JOIN
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
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
[dbo].[CollectionUser] CU ON CU.[CollectionId] = CC.[CollectionId] AND CU.[OrganizationUserId] = OU.[Id]
WHERE
C.[UserId] = @UserId
OR (
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 JSON_VALUE(C.[Folders], @UserIdPath) = @Id

View File

@ -6,7 +6,7 @@
@Key VARCHAR(MAX),
@Status TINYINT,
@Type TINYINT,
@AccessAllCollections BIT,
@AccessAll BIT,
@CreationDate DATETIME2(7),
@RevisionDate DATETIME2(7)
AS
@ -22,7 +22,7 @@ BEGIN
[Key],
[Status],
[Type],
[AccessAllCollections],
[AccessAll],
[CreationDate],
[RevisionDate]
)
@ -35,7 +35,7 @@ BEGIN
@Key,
@Status,
@Type,
@AccessAllCollections,
@AccessAll,
@CreationDate,
@RevisionDate
)

View File

@ -6,7 +6,7 @@
@Key VARCHAR(MAX),
@Status TINYINT,
@Type TINYINT,
@AccessAllCollections BIT,
@AccessAll BIT,
@CreationDate DATETIME2(7),
@RevisionDate DATETIME2(7)
AS
@ -22,7 +22,7 @@ BEGIN
[Key] = @Key,
[Status] = @Status,
[Type] = @Type,
[AccessAllCollections] = @AccessAllCollections,
[AccessAll] = @AccessAll,
[CreationDate] = @CreationDate,
[RevisionDate] = @RevisionDate
WHERE

View File

@ -6,7 +6,7 @@
[Key] VARCHAR (MAX) NULL,
[Status] TINYINT NOT NULL,
[Type] TINYINT NOT NULL,
[AccessAllCollections] BIT NOT NULL,
[AccessAll] BIT NOT NULL,
[CreationDate] DATETIME2 (7) NOT NULL,
[RevisionDate] DATETIME2 (7) NOT NULL,
CONSTRAINT [PK_OrganizationUser] PRIMARY KEY CLUSTERED ([Id] ASC),

View File

@ -2,17 +2,17 @@
AS
SELECT
OU.[Id] AS [OrganizationUserId],
OU.[AccessAllCollections],
OU.[AccessAll],
CU.[Id],
CU.[CollectionId],
U.[Name],
ISNULL(U.[Email], OU.[Email]) Email,
OU.[Status],
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
[dbo].[OrganizationUser] OU
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
[dbo].[User] U ON U.[Id] = OU.[UserId]

View File

@ -8,7 +8,7 @@ SELECT
ISNULL(U.[Email], OU.[Email]) Email,
OU.[Status],
OU.[Type],
OU.[AccessAllCollections]
OU.[AccessAll]
FROM
[dbo].[OrganizationUser] OU
LEFT JOIN