mirror of
https://github.com/bitwarden/server.git
synced 2024-11-26 12:55:17 +01:00
group access all and readonly schema changes
This commit is contained in:
parent
ba99b332e1
commit
08943ed305
@ -11,6 +11,8 @@ namespace Bit.Core.Models.Api
|
||||
[Required]
|
||||
[StringLength(300)]
|
||||
public string Name { get; set; }
|
||||
[Required]
|
||||
public bool? AccessAll { get; set; }
|
||||
public IEnumerable<string> CollectionIds { get; set; }
|
||||
|
||||
public Group ToGroup(Guid orgId)
|
||||
@ -24,6 +26,7 @@ namespace Bit.Core.Models.Api
|
||||
public Group ToGroup(Group existingGroup)
|
||||
{
|
||||
existingGroup.Name = Name;
|
||||
existingGroup.AccessAll = AccessAll.Value;
|
||||
return existingGroup;
|
||||
}
|
||||
}
|
||||
|
@ -17,11 +17,13 @@ namespace Bit.Core.Models.Api
|
||||
Id = group.Id.ToString();
|
||||
OrganizationId = group.OrganizationId.ToString();
|
||||
Name = group.Name;
|
||||
AccessAll = group.AccessAll;
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string OrganizationId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public bool AccessAll { get; set; }
|
||||
}
|
||||
|
||||
public class GroupDetailsResponseModel : GroupResponseModel
|
||||
|
11
src/Core/Models/Table/CollectionGroup.cs
Normal file
11
src/Core/Models/Table/CollectionGroup.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public class CollectionGroup
|
||||
{
|
||||
public Guid CollectionId { get; set; }
|
||||
public Guid OrganizationUserId { get; set; }
|
||||
public bool ReadOnly { get; set; }
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@ namespace Bit.Core.Models.Table
|
||||
public Guid Id { get; set; }
|
||||
public Guid OrganizationId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public bool AccessAll { get; set; }
|
||||
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
|
||||
public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow;
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
@Id UNIQUEIDENTIFIER,
|
||||
@OrganizationId UNIQUEIDENTIFIER,
|
||||
@Name VARCHAR(MAX),
|
||||
@AccessAll BIT,
|
||||
@CreationDate DATETIME2(7),
|
||||
@RevisionDate DATETIME2(7)
|
||||
AS
|
||||
@ -13,6 +14,7 @@ BEGIN
|
||||
[Id],
|
||||
[OrganizationId],
|
||||
[Name],
|
||||
[AccessAll],
|
||||
[CreationDate],
|
||||
[RevisionDate]
|
||||
)
|
||||
@ -21,6 +23,7 @@ BEGIN
|
||||
@Id,
|
||||
@OrganizationId,
|
||||
@Name,
|
||||
@AccessAll,
|
||||
@CreationDate,
|
||||
@RevisionDate
|
||||
)
|
||||
|
@ -2,6 +2,7 @@
|
||||
@Id UNIQUEIDENTIFIER,
|
||||
@OrganizationId UNIQUEIDENTIFIER,
|
||||
@Name VARCHAR(MAX),
|
||||
@AccessAll BIT,
|
||||
@CreationDate DATETIME2(7),
|
||||
@RevisionDate DATETIME2(7),
|
||||
@CollectionIds AS [dbo].[GuidIdArray] READONLY
|
||||
@ -9,7 +10,7 @@ AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
EXEC [dbo].[Group_Create] @Id, @OrganizationId, @Name, @CreationDate, @RevisionDate
|
||||
EXEC [dbo].[Group_Create] @Id, @OrganizationId, @Name, @AccessAll, @CreationDate, @RevisionDate
|
||||
|
||||
;WITH [AvailableCollectionsCTE] AS(
|
||||
SELECT
|
||||
@ -22,11 +23,13 @@ BEGIN
|
||||
INSERT INTO [dbo].[CollectionGroup]
|
||||
(
|
||||
[CollectionId],
|
||||
[GroupId]
|
||||
[GroupId],
|
||||
[ReadOnly]
|
||||
)
|
||||
SELECT
|
||||
[Id],
|
||||
@Id
|
||||
@Id,
|
||||
0
|
||||
FROM
|
||||
@CollectionIds
|
||||
WHERE
|
||||
|
@ -2,6 +2,7 @@
|
||||
@Id UNIQUEIDENTIFIER,
|
||||
@OrganizationId UNIQUEIDENTIFIER,
|
||||
@Name VARCHAR(MAX),
|
||||
@AccessAll BIT,
|
||||
@CreationDate DATETIME2(7),
|
||||
@RevisionDate DATETIME2(7)
|
||||
AS
|
||||
@ -13,6 +14,7 @@ BEGIN
|
||||
SET
|
||||
[OrganizationId] = @OrganizationId,
|
||||
[Name] = @Name,
|
||||
[AccessAll] = @AccessAll,
|
||||
[CreationDate] = @CreationDate,
|
||||
[RevisionDate] = @RevisionDate
|
||||
WHERE
|
||||
|
@ -2,6 +2,7 @@
|
||||
@Id UNIQUEIDENTIFIER,
|
||||
@OrganizationId UNIQUEIDENTIFIER,
|
||||
@Name VARCHAR(MAX),
|
||||
@AccessAll BIT,
|
||||
@CreationDate DATETIME2(7),
|
||||
@RevisionDate DATETIME2(7),
|
||||
@CollectionIds AS [dbo].[GuidIdArray] READONLY
|
||||
@ -9,7 +10,7 @@ AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
EXEC [dbo].[Group_Update] @Id, @OrganizationId, @Name, @CreationDate, @RevisionDate
|
||||
EXEC [dbo].[Group_Update] @Id, @OrganizationId, @Name, @AccessAll, @CreationDate, @RevisionDate
|
||||
|
||||
;WITH [AvailableCollectionsCTE] AS(
|
||||
SELECT
|
||||
@ -31,7 +32,8 @@ BEGIN
|
||||
INSERT VALUES
|
||||
(
|
||||
[Source].[Id],
|
||||
@Id
|
||||
@Id,
|
||||
0
|
||||
)
|
||||
WHEN NOT MATCHED BY SOURCE
|
||||
AND [Target].[GroupId] = @Id THEN
|
||||
|
@ -1,6 +1,7 @@
|
||||
CREATE TABLE [dbo].[CollectionGroup] (
|
||||
[CollectionId] UNIQUEIDENTIFIER NOT NULL,
|
||||
[GroupId] UNIQUEIDENTIFIER NOT NULL,
|
||||
[ReadOnly] BIT NOT NULL,
|
||||
CONSTRAINT [PK_CollectionGroup] PRIMARY KEY CLUSTERED ([CollectionId] ASC, [GroupId] ASC),
|
||||
CONSTRAINT [FK_CollectionGroup_Collection] FOREIGN KEY ([CollectionId]) REFERENCES [dbo].[Collection] ([Id]),
|
||||
CONSTRAINT [FK_CollectionGroup_Group] FOREIGN KEY ([GroupId]) REFERENCES [dbo].[Group] ([Id]) ON DELETE CASCADE
|
||||
|
@ -2,6 +2,7 @@
|
||||
[Id] UNIQUEIDENTIFIER NOT NULL,
|
||||
[OrganizationId] UNIQUEIDENTIFIER NOT NULL,
|
||||
[Name] NVARCHAR (50) NOT NULL,
|
||||
[AccessAll] BIT NOT NULL,
|
||||
[CreationDate] DATETIME NOT NULL,
|
||||
[RevisionDate] DATETIME NOT NULL,
|
||||
CONSTRAINT [PK_Group] PRIMARY KEY CLUSTERED ([Id] ASC),
|
||||
|
Loading…
Reference in New Issue
Block a user