mirror of
https://github.com/bitwarden/server
synced 2026-02-15 16:05:37 +00:00
Revert filescoped (#2227)
* Revert "Add git blame entry (#2226)" This reverts commit239286737d. * Revert "Turn on file scoped namespaces (#2225)" This reverts commit34fb4cca2a.
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Data;
|
||||
|
||||
namespace Bit.Core.Models.Api.Response.Accounts;
|
||||
|
||||
public class PreloginResponseModel
|
||||
namespace Bit.Core.Models.Api.Response.Accounts
|
||||
{
|
||||
public PreloginResponseModel(UserKdfInformation kdfInformation)
|
||||
public class PreloginResponseModel
|
||||
{
|
||||
Kdf = kdfInformation.Kdf;
|
||||
KdfIterations = kdfInformation.KdfIterations;
|
||||
}
|
||||
public PreloginResponseModel(UserKdfInformation kdfInformation)
|
||||
{
|
||||
Kdf = kdfInformation.Kdf;
|
||||
KdfIterations = kdfInformation.KdfIterations;
|
||||
}
|
||||
|
||||
public KdfType Kdf { get; set; }
|
||||
public int KdfIterations { get; set; }
|
||||
public KdfType Kdf { get; set; }
|
||||
public int KdfIterations { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,73 +1,74 @@
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||
|
||||
namespace Bit.Core.Models.Api;
|
||||
|
||||
public class ErrorResponseModel : ResponseModel
|
||||
namespace Bit.Core.Models.Api
|
||||
{
|
||||
public ErrorResponseModel()
|
||||
: base("error")
|
||||
{ }
|
||||
|
||||
public ErrorResponseModel(string message)
|
||||
: this()
|
||||
public class ErrorResponseModel : ResponseModel
|
||||
{
|
||||
Message = message;
|
||||
}
|
||||
public ErrorResponseModel()
|
||||
: base("error")
|
||||
{ }
|
||||
|
||||
public ErrorResponseModel(ModelStateDictionary modelState)
|
||||
: this()
|
||||
{
|
||||
Message = "The model state is invalid.";
|
||||
ValidationErrors = new Dictionary<string, IEnumerable<string>>();
|
||||
|
||||
var keys = modelState.Keys.ToList();
|
||||
var values = modelState.Values.ToList();
|
||||
|
||||
for (var i = 0; i < values.Count; i++)
|
||||
public ErrorResponseModel(string message)
|
||||
: this()
|
||||
{
|
||||
var value = values[i];
|
||||
|
||||
if (keys.Count <= i)
|
||||
{
|
||||
// Keys not available for some reason.
|
||||
break;
|
||||
}
|
||||
|
||||
var key = keys[i];
|
||||
|
||||
if (value.ValidationState != ModelValidationState.Invalid || value.Errors.Count == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var errors = value.Errors.Select(e => e.ErrorMessage);
|
||||
ValidationErrors.Add(key, errors);
|
||||
Message = message;
|
||||
}
|
||||
|
||||
public ErrorResponseModel(ModelStateDictionary modelState)
|
||||
: this()
|
||||
{
|
||||
Message = "The model state is invalid.";
|
||||
ValidationErrors = new Dictionary<string, IEnumerable<string>>();
|
||||
|
||||
var keys = modelState.Keys.ToList();
|
||||
var values = modelState.Values.ToList();
|
||||
|
||||
for (var i = 0; i < values.Count; i++)
|
||||
{
|
||||
var value = values[i];
|
||||
|
||||
if (keys.Count <= i)
|
||||
{
|
||||
// Keys not available for some reason.
|
||||
break;
|
||||
}
|
||||
|
||||
var key = keys[i];
|
||||
|
||||
if (value.ValidationState != ModelValidationState.Invalid || value.Errors.Count == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var errors = value.Errors.Select(e => e.ErrorMessage);
|
||||
ValidationErrors.Add(key, errors);
|
||||
}
|
||||
}
|
||||
|
||||
public ErrorResponseModel(Dictionary<string, IEnumerable<string>> errors)
|
||||
: this("Errors have occurred.", errors)
|
||||
{ }
|
||||
|
||||
public ErrorResponseModel(string errorKey, string errorValue)
|
||||
: this(errorKey, new string[] { errorValue })
|
||||
{ }
|
||||
|
||||
public ErrorResponseModel(string errorKey, IEnumerable<string> errorValues)
|
||||
: this(new Dictionary<string, IEnumerable<string>> { { errorKey, errorValues } })
|
||||
{ }
|
||||
|
||||
public ErrorResponseModel(string message, Dictionary<string, IEnumerable<string>> errors)
|
||||
: this()
|
||||
{
|
||||
Message = message;
|
||||
ValidationErrors = errors;
|
||||
}
|
||||
|
||||
public string Message { get; set; }
|
||||
public Dictionary<string, IEnumerable<string>> ValidationErrors { get; set; }
|
||||
// For use in development environments.
|
||||
public string ExceptionMessage { get; set; }
|
||||
public string ExceptionStackTrace { get; set; }
|
||||
public string InnerExceptionMessage { get; set; }
|
||||
}
|
||||
|
||||
public ErrorResponseModel(Dictionary<string, IEnumerable<string>> errors)
|
||||
: this("Errors have occurred.", errors)
|
||||
{ }
|
||||
|
||||
public ErrorResponseModel(string errorKey, string errorValue)
|
||||
: this(errorKey, new string[] { errorValue })
|
||||
{ }
|
||||
|
||||
public ErrorResponseModel(string errorKey, IEnumerable<string> errorValues)
|
||||
: this(new Dictionary<string, IEnumerable<string>> { { errorKey, errorValues } })
|
||||
{ }
|
||||
|
||||
public ErrorResponseModel(string message, Dictionary<string, IEnumerable<string>> errors)
|
||||
: this()
|
||||
{
|
||||
Message = message;
|
||||
ValidationErrors = errors;
|
||||
}
|
||||
|
||||
public string Message { get; set; }
|
||||
public Dictionary<string, IEnumerable<string>> ValidationErrors { get; set; }
|
||||
// For use in development environments.
|
||||
public string ExceptionMessage { get; set; }
|
||||
public string ExceptionStackTrace { get; set; }
|
||||
public string InnerExceptionMessage { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,47 +1,48 @@
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Data.Organizations.OrganizationSponsorships;
|
||||
|
||||
namespace Bit.Core.Models.Api.Response.OrganizationSponsorships;
|
||||
|
||||
public class OrganizationSponsorshipResponseModel
|
||||
namespace Bit.Core.Models.Api.Response.OrganizationSponsorships
|
||||
{
|
||||
public Guid SponsoringOrganizationUserId { get; set; }
|
||||
public string FriendlyName { get; set; }
|
||||
public string OfferedToEmail { get; set; }
|
||||
public PlanSponsorshipType PlanSponsorshipType { get; set; }
|
||||
public DateTime? LastSyncDate { get; set; }
|
||||
public DateTime? ValidUntil { get; set; }
|
||||
public bool ToDelete { get; set; }
|
||||
|
||||
public bool CloudSponsorshipRemoved { get; set; }
|
||||
|
||||
public OrganizationSponsorshipResponseModel() { }
|
||||
|
||||
public OrganizationSponsorshipResponseModel(OrganizationSponsorshipData sponsorshipData)
|
||||
public class OrganizationSponsorshipResponseModel
|
||||
{
|
||||
SponsoringOrganizationUserId = sponsorshipData.SponsoringOrganizationUserId;
|
||||
FriendlyName = sponsorshipData.FriendlyName;
|
||||
OfferedToEmail = sponsorshipData.OfferedToEmail;
|
||||
PlanSponsorshipType = sponsorshipData.PlanSponsorshipType;
|
||||
LastSyncDate = sponsorshipData.LastSyncDate;
|
||||
ValidUntil = sponsorshipData.ValidUntil;
|
||||
ToDelete = sponsorshipData.ToDelete;
|
||||
CloudSponsorshipRemoved = sponsorshipData.CloudSponsorshipRemoved;
|
||||
}
|
||||
public Guid SponsoringOrganizationUserId { get; set; }
|
||||
public string FriendlyName { get; set; }
|
||||
public string OfferedToEmail { get; set; }
|
||||
public PlanSponsorshipType PlanSponsorshipType { get; set; }
|
||||
public DateTime? LastSyncDate { get; set; }
|
||||
public DateTime? ValidUntil { get; set; }
|
||||
public bool ToDelete { get; set; }
|
||||
|
||||
public OrganizationSponsorshipData ToOrganizationSponsorship()
|
||||
{
|
||||
return new OrganizationSponsorshipData
|
||||
public bool CloudSponsorshipRemoved { get; set; }
|
||||
|
||||
public OrganizationSponsorshipResponseModel() { }
|
||||
|
||||
public OrganizationSponsorshipResponseModel(OrganizationSponsorshipData sponsorshipData)
|
||||
{
|
||||
SponsoringOrganizationUserId = SponsoringOrganizationUserId,
|
||||
FriendlyName = FriendlyName,
|
||||
OfferedToEmail = OfferedToEmail,
|
||||
PlanSponsorshipType = PlanSponsorshipType,
|
||||
LastSyncDate = LastSyncDate,
|
||||
ValidUntil = ValidUntil,
|
||||
ToDelete = ToDelete,
|
||||
CloudSponsorshipRemoved = CloudSponsorshipRemoved
|
||||
};
|
||||
SponsoringOrganizationUserId = sponsorshipData.SponsoringOrganizationUserId;
|
||||
FriendlyName = sponsorshipData.FriendlyName;
|
||||
OfferedToEmail = sponsorshipData.OfferedToEmail;
|
||||
PlanSponsorshipType = sponsorshipData.PlanSponsorshipType;
|
||||
LastSyncDate = sponsorshipData.LastSyncDate;
|
||||
ValidUntil = sponsorshipData.ValidUntil;
|
||||
ToDelete = sponsorshipData.ToDelete;
|
||||
CloudSponsorshipRemoved = sponsorshipData.CloudSponsorshipRemoved;
|
||||
}
|
||||
|
||||
public OrganizationSponsorshipData ToOrganizationSponsorship()
|
||||
{
|
||||
return new OrganizationSponsorshipData
|
||||
{
|
||||
SponsoringOrganizationUserId = SponsoringOrganizationUserId,
|
||||
FriendlyName = FriendlyName,
|
||||
OfferedToEmail = OfferedToEmail,
|
||||
PlanSponsorshipType = PlanSponsorshipType,
|
||||
LastSyncDate = LastSyncDate,
|
||||
ValidUntil = ValidUntil,
|
||||
ToDelete = ToDelete,
|
||||
CloudSponsorshipRemoved = CloudSponsorshipRemoved
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,30 @@
|
||||
using Bit.Core.Models.Data.Organizations.OrganizationSponsorships;
|
||||
|
||||
namespace Bit.Core.Models.Api.Response.OrganizationSponsorships;
|
||||
|
||||
public class OrganizationSponsorshipSyncResponseModel
|
||||
namespace Bit.Core.Models.Api.Response.OrganizationSponsorships
|
||||
{
|
||||
public IEnumerable<OrganizationSponsorshipResponseModel> SponsorshipsBatch { get; set; }
|
||||
|
||||
public OrganizationSponsorshipSyncResponseModel() { }
|
||||
|
||||
public OrganizationSponsorshipSyncResponseModel(OrganizationSponsorshipSyncData syncData)
|
||||
public class OrganizationSponsorshipSyncResponseModel
|
||||
{
|
||||
if (syncData == null)
|
||||
public IEnumerable<OrganizationSponsorshipResponseModel> SponsorshipsBatch { get; set; }
|
||||
|
||||
public OrganizationSponsorshipSyncResponseModel() { }
|
||||
|
||||
public OrganizationSponsorshipSyncResponseModel(OrganizationSponsorshipSyncData syncData)
|
||||
{
|
||||
return;
|
||||
if (syncData == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
SponsorshipsBatch = syncData.SponsorshipsBatch.Select(o => new OrganizationSponsorshipResponseModel(o));
|
||||
|
||||
}
|
||||
SponsorshipsBatch = syncData.SponsorshipsBatch.Select(o => new OrganizationSponsorshipResponseModel(o));
|
||||
|
||||
}
|
||||
|
||||
public OrganizationSponsorshipSyncData ToOrganizationSponsorshipSync()
|
||||
{
|
||||
return new OrganizationSponsorshipSyncData()
|
||||
public OrganizationSponsorshipSyncData ToOrganizationSponsorshipSync()
|
||||
{
|
||||
SponsorshipsBatch = SponsorshipsBatch.Select(o => o.ToOrganizationSponsorship())
|
||||
};
|
||||
}
|
||||
return new OrganizationSponsorshipSyncData()
|
||||
{
|
||||
SponsorshipsBatch = SponsorshipsBatch.Select(o => o.ToOrganizationSponsorship())
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Bit.Core.Models.Api;
|
||||
|
||||
public abstract class ResponseModel
|
||||
namespace Bit.Core.Models.Api
|
||||
{
|
||||
public ResponseModel(string obj)
|
||||
public abstract class ResponseModel
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(obj))
|
||||
public ResponseModel(string obj)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
if (string.IsNullOrWhiteSpace(obj))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
}
|
||||
|
||||
Object = obj;
|
||||
}
|
||||
|
||||
Object = obj;
|
||||
[JsonProperty(Order = -200)] // Always the first property
|
||||
public string Object { get; private set; }
|
||||
}
|
||||
|
||||
[JsonProperty(Order = -200)] // Always the first property
|
||||
public string Object { get; private set; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user