mirror of
https://github.com/bitwarden/server.git
synced 2025-07-03 00:52:49 -05:00
remove deprecated code
This commit is contained in:
@ -8,38 +8,16 @@ namespace Bit.Core.Models.Api
|
||||
{
|
||||
public LoginDataModel() { }
|
||||
|
||||
public LoginDataModel(LoginRequestModel login)
|
||||
{
|
||||
Name = login.Name;
|
||||
Notes = login.Notes;
|
||||
Fields = login.Fields;
|
||||
|
||||
Uri = login.Uri;
|
||||
Username = login.Username;
|
||||
Password = login.Password;
|
||||
Totp = login.Totp;
|
||||
}
|
||||
|
||||
public LoginDataModel(CipherRequestModel cipher)
|
||||
{
|
||||
Name = cipher.Name;
|
||||
Notes = cipher.Notes;
|
||||
Fields = cipher.Fields;
|
||||
|
||||
if(cipher.Login == null)
|
||||
{
|
||||
Uri = cipher.Uri;
|
||||
Username = cipher.Username;
|
||||
Password = cipher.Password;
|
||||
Totp = cipher.Totp;
|
||||
}
|
||||
else
|
||||
{
|
||||
Uri = cipher.Login.Uri;
|
||||
Username = cipher.Login.Username;
|
||||
Password = cipher.Login.Password;
|
||||
Totp = cipher.Login.Totp;
|
||||
}
|
||||
Uri = cipher.Login.Uri;
|
||||
Username = cipher.Login.Username;
|
||||
Password = cipher.Login.Password;
|
||||
Totp = cipher.Login.Totp;
|
||||
}
|
||||
|
||||
public LoginDataModel(Cipher cipher)
|
||||
|
@ -32,23 +32,6 @@ namespace Bit.Core.Models.Api
|
||||
public CardType Card { get; set; }
|
||||
public SecureNoteType SecureNote { get; set; }
|
||||
|
||||
[Obsolete("Use Login property")]
|
||||
[EncryptedString]
|
||||
[StringLength(10000)]
|
||||
public string Uri { get; set; }
|
||||
[Obsolete("Use Login property")]
|
||||
[EncryptedString]
|
||||
[StringLength(1000)]
|
||||
public string Username { get; set; }
|
||||
[Obsolete("Use Login property")]
|
||||
[EncryptedString]
|
||||
[StringLength(1000)]
|
||||
public string Password { get; set; }
|
||||
[Obsolete("Use Login property")]
|
||||
[EncryptedString]
|
||||
[StringLength(1000)]
|
||||
public string Totp { get; set; }
|
||||
|
||||
public CipherDetails ToCipherDetails(Guid userId)
|
||||
{
|
||||
var cipher = new CipherDetails
|
||||
|
@ -1,92 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Bit.Core.Utilities;
|
||||
using Newtonsoft.Json;
|
||||
using Core.Models.Data;
|
||||
using Bit.Core.Models.Table;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Bit.Core.Models.Api
|
||||
{
|
||||
public class LoginRequestModel
|
||||
{
|
||||
[StringLength(36)]
|
||||
public string OrganizationId { get; set; }
|
||||
[StringLength(36)]
|
||||
public string FolderId { get; set; }
|
||||
public bool Favorite { get; set; }
|
||||
[Required]
|
||||
[EncryptedString]
|
||||
[StringLength(1000)]
|
||||
public string Name { get; set; }
|
||||
[EncryptedString]
|
||||
[StringLength(10000)]
|
||||
public string Uri { get; set; }
|
||||
[EncryptedString]
|
||||
[StringLength(1000)]
|
||||
public string Username { get; set; }
|
||||
[EncryptedString]
|
||||
[StringLength(1000)]
|
||||
public string Password { get; set; }
|
||||
[EncryptedString]
|
||||
[StringLength(10000)]
|
||||
public string Notes { get; set; }
|
||||
[EncryptedString]
|
||||
[StringLength(1000)]
|
||||
public string Totp { get; set; }
|
||||
public IEnumerable<FieldDataModel> Fields { get; set; }
|
||||
|
||||
public CipherDetails ToCipherDetails(Guid userId)
|
||||
{
|
||||
return ToCipherDetails(new CipherDetails
|
||||
{
|
||||
UserId = string.IsNullOrWhiteSpace(OrganizationId) ? (Guid?)userId : null,
|
||||
OrganizationId = string.IsNullOrWhiteSpace(OrganizationId) ? (Guid?)null : new Guid(OrganizationId),
|
||||
Edit = true
|
||||
});
|
||||
}
|
||||
|
||||
public CipherDetails ToOrganizationCipherDetails(Guid orgId)
|
||||
{
|
||||
return ToCipherDetails(new CipherDetails
|
||||
{
|
||||
OrganizationId = orgId,
|
||||
Edit = true
|
||||
});
|
||||
}
|
||||
|
||||
public Cipher ToOrganizationCipher()
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(OrganizationId))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(OrganizationId));
|
||||
}
|
||||
|
||||
return ToCipher(new Cipher
|
||||
{
|
||||
OrganizationId = new Guid(OrganizationId)
|
||||
});
|
||||
}
|
||||
|
||||
public CipherDetails ToCipherDetails(CipherDetails existingLogin)
|
||||
{
|
||||
existingLogin.FolderId = string.IsNullOrWhiteSpace(FolderId) ? null : (Guid?)new Guid(FolderId);
|
||||
existingLogin.Favorite = Favorite;
|
||||
|
||||
existingLogin.Data = JsonConvert.SerializeObject(new LoginDataModel(this),
|
||||
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
|
||||
existingLogin.Type = Enums.CipherType.Login;
|
||||
|
||||
return existingLogin;
|
||||
}
|
||||
|
||||
public Cipher ToCipher(Cipher existingLogin)
|
||||
{
|
||||
existingLogin.Data = JsonConvert.SerializeObject(new LoginDataModel(this),
|
||||
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
|
||||
existingLogin.Type = Enums.CipherType.Login;
|
||||
|
||||
return existingLogin;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
using System;
|
||||
using Core.Models.Data;
|
||||
using Bit.Core.Models.Table;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Bit.Core.Models.Api
|
||||
{
|
||||
public class LoginResponseModel : ResponseModel
|
||||
{
|
||||
public LoginResponseModel(Cipher cipher, GlobalSettings globalSettings, bool orgUseTotp, string obj = "login")
|
||||
: base(obj)
|
||||
{
|
||||
if(cipher == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(cipher));
|
||||
}
|
||||
|
||||
if(cipher.Type != Enums.CipherType.Login)
|
||||
{
|
||||
throw new ArgumentException(nameof(cipher.Type));
|
||||
}
|
||||
|
||||
var data = new LoginDataModel(cipher);
|
||||
|
||||
Id = cipher.Id.ToString();
|
||||
OrganizationId = cipher.OrganizationId?.ToString();
|
||||
Name = data.Name;
|
||||
Uri = data.Uri;
|
||||
Username = data.Username;
|
||||
Password = data.Password;
|
||||
Notes = data.Notes;
|
||||
Totp = data.Totp;
|
||||
RevisionDate = cipher.RevisionDate;
|
||||
Edit = true;
|
||||
OrganizationUseTotp = orgUseTotp;
|
||||
Attachments = AttachmentResponseModel.FromCipher(cipher, globalSettings);
|
||||
}
|
||||
|
||||
public LoginResponseModel(CipherDetails cipher, GlobalSettings globalSettings, string obj = "login")
|
||||
: this(cipher as Cipher, globalSettings, cipher.OrganizationUseTotp, obj)
|
||||
{
|
||||
FolderId = cipher.FolderId?.ToString();
|
||||
Favorite = cipher.Favorite;
|
||||
Edit = cipher.Edit;
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string OrganizationId { get; set; }
|
||||
public string FolderId { get; set; }
|
||||
public bool Favorite { get; set; }
|
||||
public bool Edit { get; set; }
|
||||
public bool OrganizationUseTotp { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Uri { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string Password { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public string Totp { get; set; }
|
||||
public IEnumerable<AttachmentResponseModel> Attachments { get; set; }
|
||||
public DateTime RevisionDate { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user