2015-12-08 22:57:38 -05:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
2017-03-08 21:55:08 -05:00
|
|
|
|
using Bit.Core.Utilities;
|
2017-03-08 21:45:08 -05:00
|
|
|
|
using Bit.Core.Models.Table;
|
2016-05-21 17:16:22 -04:00
|
|
|
|
using Newtonsoft.Json;
|
2017-03-18 11:58:02 -04:00
|
|
|
|
using Core.Models.Data;
|
2015-12-08 22:57:38 -05:00
|
|
|
|
|
2017-03-08 21:55:08 -05:00
|
|
|
|
namespace Bit.Core.Models.Api
|
2015-12-08 22:57:38 -05:00
|
|
|
|
{
|
2017-01-02 21:52:13 -05:00
|
|
|
|
public class LoginRequestModel
|
2015-12-08 22:57:38 -05:00
|
|
|
|
{
|
2015-12-30 21:40:19 -05:00
|
|
|
|
[StringLength(36)]
|
2015-12-08 22:57:38 -05:00
|
|
|
|
public string FolderId { get; set; }
|
2016-06-08 22:19:08 -04:00
|
|
|
|
public bool Favorite { get; set; }
|
2015-12-08 22:57:38 -05:00
|
|
|
|
[Required]
|
|
|
|
|
|
[EncryptedString]
|
2015-12-30 21:40:19 -05:00
|
|
|
|
[StringLength(300)]
|
2015-12-08 22:57:38 -05:00
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
[EncryptedString]
|
2016-10-13 18:45:33 -04:00
|
|
|
|
[StringLength(10000)]
|
2015-12-08 22:57:38 -05:00
|
|
|
|
public string Uri { get; set; }
|
|
|
|
|
|
[EncryptedString]
|
2016-10-13 18:45:33 -04:00
|
|
|
|
[StringLength(300)]
|
2015-12-08 22:57:38 -05:00
|
|
|
|
public string Username { get; set; }
|
|
|
|
|
|
[EncryptedString]
|
2015-12-30 21:40:19 -05:00
|
|
|
|
[StringLength(300)]
|
2015-12-08 22:57:38 -05:00
|
|
|
|
public string Password { get; set; }
|
|
|
|
|
|
[EncryptedString]
|
2016-10-13 18:45:33 -04:00
|
|
|
|
[StringLength(10000)]
|
2015-12-08 22:57:38 -05:00
|
|
|
|
public string Notes { get; set; }
|
|
|
|
|
|
|
2017-03-18 11:58:02 -04:00
|
|
|
|
public CipherDetails ToCipher(Guid userId)
|
2015-12-08 22:57:38 -05:00
|
|
|
|
{
|
2017-03-18 11:58:02 -04:00
|
|
|
|
return ToCipher(new CipherDetails
|
2015-12-08 22:57:38 -05:00
|
|
|
|
{
|
2017-01-24 22:46:54 -05:00
|
|
|
|
UserId = userId
|
2016-06-08 22:00:31 -04:00
|
|
|
|
});
|
2015-12-08 22:57:38 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-03-18 11:58:02 -04:00
|
|
|
|
public CipherDetails ToCipher(CipherDetails existingLogin)
|
2015-12-08 22:57:38 -05:00
|
|
|
|
{
|
2017-01-02 21:52:13 -05:00
|
|
|
|
existingLogin.FolderId = string.IsNullOrWhiteSpace(FolderId) ? null : (Guid?)new Guid(FolderId);
|
|
|
|
|
|
existingLogin.Favorite = Favorite;
|
2017-03-18 11:58:02 -04:00
|
|
|
|
|
2017-01-02 21:52:13 -05:00
|
|
|
|
existingLogin.Data = JsonConvert.SerializeObject(new LoginDataModel(this),
|
|
|
|
|
|
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
|
2017-03-18 11:58:02 -04:00
|
|
|
|
existingLogin.Type = Enums.CipherType.Login;
|
2015-12-08 22:57:38 -05:00
|
|
|
|
|
2017-01-02 21:52:13 -05:00
|
|
|
|
return existingLogin;
|
2015-12-08 22:57:38 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|