mirror of
https://github.com/bitwarden/server
synced 2025-12-17 00:33:23 +00:00
move all models into core
This commit is contained in:
51
src/Core/Models/Api/LoginDataModel.cs
Normal file
51
src/Core/Models/Api/LoginDataModel.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using Bit.Core.Models.Table;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Bit.Core.Models.Api
|
||||
{
|
||||
public class LoginDataModel
|
||||
{
|
||||
public LoginDataModel() { }
|
||||
|
||||
public LoginDataModel(LoginRequestModel login)
|
||||
{
|
||||
Name = login.Name;
|
||||
Uri = login.Uri;
|
||||
Username = login.Username;
|
||||
Password = login.Password;
|
||||
Notes = login.Notes;
|
||||
}
|
||||
|
||||
public LoginDataModel(CipherRequestModel cipher)
|
||||
{
|
||||
Name = cipher.Name;
|
||||
Uri = cipher.Uri;
|
||||
Username = cipher.Username;
|
||||
Password = cipher.Password;
|
||||
Notes = cipher.Notes;
|
||||
}
|
||||
|
||||
public LoginDataModel(Cipher cipher)
|
||||
{
|
||||
if(cipher.Type != Core.Enums.CipherType.Login)
|
||||
{
|
||||
throw new ArgumentException("Cipher is not correct type.");
|
||||
}
|
||||
|
||||
var data = JsonConvert.DeserializeObject<LoginDataModel>(cipher.Data);
|
||||
|
||||
Name = data.Name;
|
||||
Uri = data.Uri;
|
||||
Username = data.Username;
|
||||
Password = data.Password;
|
||||
Notes = data.Notes;
|
||||
}
|
||||
|
||||
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; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user