2021-05-12 11:18:25 +02:00
|
|
|
|
using System;
|
2017-03-09 23:58:43 -05:00
|
|
|
|
using System.Collections.Generic;
|
2017-03-28 22:03:57 -04:00
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
2017-05-18 12:04:27 -04:00
|
|
|
|
using System.Linq;
|
2021-01-12 11:02:39 -05:00
|
|
|
|
using System.Text.Json;
|
2022-05-19 15:55:42 -04:00
|
|
|
|
using Bit.Api.Models.Request.Accounts;
|
2022-01-11 10:40:51 +01:00
|
|
|
|
using Bit.Core.Entities;
|
2021-12-14 15:05:07 +00:00
|
|
|
|
using Bit.Core.Enums;
|
|
|
|
|
|
using Bit.Core.Models.Data;
|
2022-05-10 17:12:09 -04:00
|
|
|
|
using Bit.Core.Models.Data.Organizations.OrganizationUsers;
|
2021-06-30 09:35:26 +02:00
|
|
|
|
using Bit.Core.Utilities;
|
2017-03-09 23:58:43 -05:00
|
|
|
|
|
2021-12-14 15:05:07 +00:00
|
|
|
|
namespace Bit.Api.Models.Request.Organizations
|
2017-03-09 23:58:43 -05:00
|
|
|
|
{
|
2021-06-30 09:35:26 +02:00
|
|
|
|
public class OrganizationUserInviteRequestModel
|
2017-03-09 23:58:43 -05:00
|
|
|
|
{
|
2017-03-28 22:03:57 -04:00
|
|
|
|
[Required]
|
2021-07-16 08:01:51 +10:00
|
|
|
|
[StrictEmailAddressList]
|
2017-05-18 12:04:27 -04:00
|
|
|
|
public IEnumerable<string> Emails { get; set; }
|
2017-03-28 22:03:57 -04:00
|
|
|
|
[Required]
|
2021-12-14 15:05:07 +00:00
|
|
|
|
public OrganizationUserType? Type { get; set; }
|
2017-04-27 15:35:26 -04:00
|
|
|
|
public bool AccessAll { get; set; }
|
2021-01-12 11:02:39 -05:00
|
|
|
|
public Permissions Permissions { get; set; }
|
2017-05-11 11:41:13 -04:00
|
|
|
|
public IEnumerable<SelectionReadOnlyRequestModel> Collections { get; set; }
|
2021-12-14 15:05:07 +00:00
|
|
|
|
|
|
|
|
|
|
public OrganizationUserInviteData ToData()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new OrganizationUserInviteData
|
|
|
|
|
|
{
|
|
|
|
|
|
Emails = Emails,
|
|
|
|
|
|
Type = Type,
|
|
|
|
|
|
AccessAll = AccessAll,
|
2021-12-20 15:28:07 +10:00
|
|
|
|
Collections = Collections?.Select(c => c.ToSelectionReadOnly()),
|
2021-12-14 15:05:07 +00:00
|
|
|
|
Permissions = Permissions,
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
2017-03-09 23:58:43 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class OrganizationUserAcceptRequestModel
|
|
|
|
|
|
{
|
2017-03-28 22:03:57 -04:00
|
|
|
|
[Required]
|
2017-03-09 23:58:43 -05:00
|
|
|
|
public string Token { get; set; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class OrganizationUserConfirmRequestModel
|
|
|
|
|
|
{
|
2017-03-28 22:03:57 -04:00
|
|
|
|
[Required]
|
2017-03-09 23:58:43 -05:00
|
|
|
|
public string Key { get; set; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-05-25 19:23:47 +02:00
|
|
|
|
public class OrganizationUserBulkConfirmRequestModelEntry
|
|
|
|
|
|
{
|
|
|
|
|
|
[Required]
|
|
|
|
|
|
public Guid Id { get; set; }
|
|
|
|
|
|
[Required]
|
|
|
|
|
|
public string Key { get; set; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class OrganizationUserBulkConfirmRequestModel
|
|
|
|
|
|
{
|
|
|
|
|
|
[Required]
|
|
|
|
|
|
public IEnumerable<OrganizationUserBulkConfirmRequestModelEntry> Keys { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public Dictionary<Guid, string> ToDictionary()
|
|
|
|
|
|
{
|
|
|
|
|
|
return Keys.ToDictionary(e => e.Id, e => e.Key);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-03-09 23:58:43 -05:00
|
|
|
|
public class OrganizationUserUpdateRequestModel
|
|
|
|
|
|
{
|
2017-03-28 22:03:57 -04:00
|
|
|
|
[Required]
|
2021-12-14 15:05:07 +00:00
|
|
|
|
public OrganizationUserType? Type { get; set; }
|
2017-04-27 15:35:26 -04:00
|
|
|
|
public bool AccessAll { get; set; }
|
2021-01-12 11:02:39 -05:00
|
|
|
|
public Permissions Permissions { get; set; }
|
2017-05-11 11:41:13 -04:00
|
|
|
|
public IEnumerable<SelectionReadOnlyRequestModel> Collections { get; set; }
|
2017-03-13 23:31:17 -04:00
|
|
|
|
|
|
|
|
|
|
public OrganizationUser ToOrganizationUser(OrganizationUser existingUser)
|
|
|
|
|
|
{
|
2017-03-28 22:03:57 -04:00
|
|
|
|
existingUser.Type = Type.Value;
|
2021-01-12 11:02:39 -05:00
|
|
|
|
existingUser.Permissions = JsonSerializer.Serialize(Permissions, new JsonSerializerOptions
|
|
|
|
|
|
{
|
|
|
|
|
|
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
|
|
|
|
|
});
|
2017-04-27 15:35:26 -04:00
|
|
|
|
existingUser.AccessAll = AccessAll;
|
2017-03-13 23:31:17 -04:00
|
|
|
|
return existingUser;
|
|
|
|
|
|
}
|
2017-03-11 22:42:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-05-09 19:04:01 -04:00
|
|
|
|
public class OrganizationUserUpdateGroupsRequestModel
|
|
|
|
|
|
{
|
|
|
|
|
|
[Required]
|
|
|
|
|
|
public IEnumerable<string> GroupIds { get; set; }
|
|
|
|
|
|
}
|
2021-12-16 15:35:09 +01:00
|
|
|
|
|
2022-05-19 15:55:42 -04:00
|
|
|
|
public class OrganizationUserResetPasswordEnrollmentRequestModel : SecretVerificationRequestModel
|
2021-03-30 09:48:52 -05:00
|
|
|
|
{
|
|
|
|
|
|
public string ResetPasswordKey { get; set; }
|
|
|
|
|
|
}
|
2021-05-12 11:18:25 +02:00
|
|
|
|
|
2021-05-17 10:10:44 +02:00
|
|
|
|
public class OrganizationUserBulkRequestModel
|
2021-05-12 11:18:25 +02:00
|
|
|
|
{
|
|
|
|
|
|
[Required]
|
|
|
|
|
|
public IEnumerable<Guid> Ids { get; set; }
|
|
|
|
|
|
}
|
2017-03-09 23:58:43 -05:00
|
|
|
|
}
|