mirror of
https://github.com/bitwarden/server
synced 2025-12-13 06:43:45 +00:00
move all models into core
This commit is contained in:
50
src/Core/Models/Api/Request/LoginRequestModel.cs
Normal file
50
src/Core/Models/Api/Request/LoginRequestModel.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Bit.Core.Utilities;
|
||||
using Bit.Core.Models.Table;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Bit.Core.Models.Api
|
||||
{
|
||||
public class LoginRequestModel
|
||||
{
|
||||
[StringLength(36)]
|
||||
public string FolderId { get; set; }
|
||||
public bool Favorite { get; set; }
|
||||
[Required]
|
||||
[EncryptedString]
|
||||
[StringLength(300)]
|
||||
public string Name { get; set; }
|
||||
[EncryptedString]
|
||||
[StringLength(10000)]
|
||||
public string Uri { get; set; }
|
||||
[EncryptedString]
|
||||
[StringLength(300)]
|
||||
public string Username { get; set; }
|
||||
[EncryptedString]
|
||||
[StringLength(300)]
|
||||
public string Password { get; set; }
|
||||
[EncryptedString]
|
||||
[StringLength(10000)]
|
||||
public string Notes { get; set; }
|
||||
|
||||
public Cipher ToCipher(Guid userId)
|
||||
{
|
||||
return ToCipher(new Cipher
|
||||
{
|
||||
UserId = userId
|
||||
});
|
||||
}
|
||||
|
||||
public Cipher ToCipher(Cipher 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 = Core.Enums.CipherType.Login;
|
||||
|
||||
return existingLogin;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user