Files
server/src/Api/Models/Request/Organizations/OrganizationUserRequestModels.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

105 lines
3.0 KiB
C#
Raw Normal View History

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;
using System.Text.Json;
2021-12-14 15:05:07 +00:00
using Bit.Core.Enums;
using Bit.Core.Models.Data;
using Bit.Core.Models.Table;
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]
[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; }
public bool AccessAll { get; set; }
public Permissions Permissions { get; set; }
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,
Collections = Collections.Select(c => c.ToSelectionReadOnly()),
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; }
}
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; }
public bool AccessAll { get; set; }
public Permissions Permissions { get; set; }
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;
existingUser.Permissions = JsonSerializer.Serialize(Permissions, new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
});
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
public class OrganizationUserResetPasswordEnrollmentRequestModel
{
public string ResetPasswordKey { get; set; }
}
public class OrganizationUserBulkRequestModel
{
[Required]
public IEnumerable<Guid> Ids { get; set; }
}
2017-03-09 23:58:43 -05:00
}