mirror of
https://github.com/bitwarden/android.git
synced 2024-12-25 02:18:27 +03:00
model adjustments
This commit is contained in:
parent
665e66a9a6
commit
18a86d3f12
14 changed files with 153 additions and 25 deletions
|
@ -103,7 +103,7 @@
|
||||||
<Compile Include="Models\Api\Request\LoginRequest.cs" />
|
<Compile Include="Models\Api\Request\LoginRequest.cs" />
|
||||||
<Compile Include="Models\Api\Request\PasswordHintRequest.cs" />
|
<Compile Include="Models\Api\Request\PasswordHintRequest.cs" />
|
||||||
<Compile Include="Models\Api\Request\TokenRequest.cs" />
|
<Compile Include="Models\Api\Request\TokenRequest.cs" />
|
||||||
<Compile Include="Models\Api\Response\CipherHistoryResponse.cs" />
|
<Compile Include="Models\Api\Response\AttachmentResponse.cs" />
|
||||||
<Compile Include="Models\Api\Response\CipherResponse.cs" />
|
<Compile Include="Models\Api\Response\CipherResponse.cs" />
|
||||||
<Compile Include="Models\Api\Response\DomainsResponse.cs" />
|
<Compile Include="Models\Api\Response\DomainsResponse.cs" />
|
||||||
<Compile Include="Models\Api\Response\ErrorResponse.cs" />
|
<Compile Include="Models\Api\Response\ErrorResponse.cs" />
|
||||||
|
@ -116,8 +116,9 @@
|
||||||
<Compile Include="Models\Api\Response\TokenResponse.cs" />
|
<Compile Include="Models\Api\Response\TokenResponse.cs" />
|
||||||
<Compile Include="Models\Api\Response\ProfileResponse.cs" />
|
<Compile Include="Models\Api\Response\ProfileResponse.cs" />
|
||||||
<Compile Include="Models\Api\LoginDataModel.cs" />
|
<Compile Include="Models\Api\LoginDataModel.cs" />
|
||||||
<Compile Include="Models\Cipher.cs" />
|
|
||||||
<Compile Include="Models\CipherString.cs" />
|
<Compile Include="Models\CipherString.cs" />
|
||||||
|
<Compile Include="Models\Data\AttachmentData.cs" />
|
||||||
|
<Compile Include="Models\Attachment.cs" />
|
||||||
<Compile Include="Models\SymmetricCryptoKey.cs" />
|
<Compile Include="Models\SymmetricCryptoKey.cs" />
|
||||||
<Compile Include="Models\Data\SettingsData.cs" />
|
<Compile Include="Models\Data\SettingsData.cs" />
|
||||||
<Compile Include="Models\Data\FolderData.cs" />
|
<Compile Include="Models\Data\FolderData.cs" />
|
||||||
|
|
|
@ -7,5 +7,6 @@
|
||||||
public string Username { get; set; }
|
public string Username { get; set; }
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
public string Notes { get; set; }
|
public string Notes { get; set; }
|
||||||
|
public string Totp { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
11
src/App/Models/Api/Response/AttachmentResponse.cs
Normal file
11
src/App/Models/Api/Response/AttachmentResponse.cs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
namespace Bit.App.Models.Api
|
||||||
|
{
|
||||||
|
public class AttachmentResponse
|
||||||
|
{
|
||||||
|
public string Id { get; set; }
|
||||||
|
public string Url { get; set; }
|
||||||
|
public string FileName { get; set; }
|
||||||
|
public string Size { get; set; }
|
||||||
|
public string SizeName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,10 +0,0 @@
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Bit.App.Models.Api
|
|
||||||
{
|
|
||||||
public class CipherHistoryResponse
|
|
||||||
{
|
|
||||||
public IEnumerable<CipherResponse> Revised { get; set; }
|
|
||||||
public IEnumerable<string> Deleted { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +1,7 @@
|
||||||
using Bit.App.Enums;
|
using Bit.App.Enums;
|
||||||
using System;
|
using System;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Bit.App.Models.Api
|
namespace Bit.App.Models.Api
|
||||||
{
|
{
|
||||||
|
@ -12,7 +13,10 @@ namespace Bit.App.Models.Api
|
||||||
public string OrganizationId { get; set; }
|
public string OrganizationId { get; set; }
|
||||||
public CipherType Type { get; set; }
|
public CipherType Type { get; set; }
|
||||||
public bool Favorite { get; set; }
|
public bool Favorite { get; set; }
|
||||||
|
public bool Edit { get; set; }
|
||||||
|
public bool OrganizationUseTotp { get; set; }
|
||||||
public JObject Data { get; set; }
|
public JObject Data { get; set; }
|
||||||
|
public IEnumerable<AttachmentResponse> Attachments { get; set; }
|
||||||
public DateTime RevisionDate { get; set; }
|
public DateTime RevisionDate { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Bit.App.Models.Api
|
namespace Bit.App.Models.Api
|
||||||
{
|
{
|
||||||
|
@ -13,7 +14,11 @@ namespace Bit.App.Models.Api
|
||||||
public string Username { get; set; }
|
public string Username { get; set; }
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
public string Notes { get; set; }
|
public string Notes { get; set; }
|
||||||
|
public string Totp { get; set; }
|
||||||
public bool Favorite { get; set; }
|
public bool Favorite { get; set; }
|
||||||
|
public bool Edit { get; set; }
|
||||||
|
public bool OrganizationUseTotp { get; set; }
|
||||||
|
public IEnumerable<AttachmentResponse> Attachments { get; set; }
|
||||||
public DateTime RevisionDate { get; set; }
|
public DateTime RevisionDate { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,12 @@ namespace Bit.App.Models.Api
|
||||||
{
|
{
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
public bool UseGroups { get; set; }
|
||||||
|
public bool UseDirectory { get; set; }
|
||||||
|
public bool UseTotp { get; set; }
|
||||||
|
public int Seats { get; set; }
|
||||||
|
public int MaxCollections { get; set; }
|
||||||
|
public short? MaxStorageGb { get; set; }
|
||||||
public string Key { get; set; }
|
public string Key { get; set; }
|
||||||
public OrganizationUserStatusType Status { get; set; }
|
public OrganizationUserStatusType Status { get; set; }
|
||||||
public OrganizationUserType Type { get; set; }
|
public OrganizationUserType Type { get; set; }
|
||||||
|
|
|
@ -7,6 +7,8 @@ namespace Bit.App.Models.Api
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string Email { get; set; }
|
public string Email { get; set; }
|
||||||
|
public bool EmailVerified { get; set; }
|
||||||
|
public bool Premium { get; set; }
|
||||||
public string MasterPasswordHint { get; set; }
|
public string MasterPasswordHint { get; set; }
|
||||||
public string Culture { get; set; }
|
public string Culture { get; set; }
|
||||||
public bool TwoFactorEnabled { get; set; }
|
public bool TwoFactorEnabled { get; set; }
|
||||||
|
|
40
src/App/Models/Attachment.cs
Normal file
40
src/App/Models/Attachment.cs
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
using Bit.App.Models.Api;
|
||||||
|
using Bit.App.Models.Data;
|
||||||
|
|
||||||
|
namespace Bit.App.Models
|
||||||
|
{
|
||||||
|
public class Attachment
|
||||||
|
{
|
||||||
|
public Attachment()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
public Attachment(AttachmentData data)
|
||||||
|
{
|
||||||
|
Id = data.Id;
|
||||||
|
Url = data.Url;
|
||||||
|
FileName = data.FileName;
|
||||||
|
Size = data.Size;
|
||||||
|
SizeName = data.SizeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Attachment(AttachmentResponse response)
|
||||||
|
{
|
||||||
|
Id = response.Id;
|
||||||
|
Url = response.Url;
|
||||||
|
FileName = response.FileName;
|
||||||
|
Size = response.Size;
|
||||||
|
SizeName = response.SizeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Id { get; set; }
|
||||||
|
public string Url { get; set; }
|
||||||
|
public string FileName { get; set; }
|
||||||
|
public string Size { get; set; }
|
||||||
|
public string SizeName { get; set; }
|
||||||
|
|
||||||
|
public AttachmentData ToAttachmentData(string loginId)
|
||||||
|
{
|
||||||
|
return new AttachmentData(this, loginId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,10 +0,0 @@
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Bit.App.Models
|
|
||||||
{
|
|
||||||
public abstract class Cipher
|
|
||||||
{
|
|
||||||
public string Id { get; set; }
|
|
||||||
public CipherString Name { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
47
src/App/Models/Data/AttachmentData.cs
Normal file
47
src/App/Models/Data/AttachmentData.cs
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
using SQLite;
|
||||||
|
using Bit.App.Abstractions;
|
||||||
|
using Bit.App.Models.Api;
|
||||||
|
|
||||||
|
namespace Bit.App.Models.Data
|
||||||
|
{
|
||||||
|
[Table("Attachment")]
|
||||||
|
public class AttachmentData : IDataObject<string>
|
||||||
|
{
|
||||||
|
public AttachmentData()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
public AttachmentData(Attachment attachment, string loginId)
|
||||||
|
{
|
||||||
|
Id = attachment.Id;
|
||||||
|
LoginId = loginId;
|
||||||
|
Url = attachment.Url;
|
||||||
|
FileName = attachment.FileName;
|
||||||
|
Size = attachment.Size;
|
||||||
|
SizeName = attachment.SizeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AttachmentData(AttachmentResponse response, string loginId)
|
||||||
|
{
|
||||||
|
Id = response.Id;
|
||||||
|
LoginId = loginId;
|
||||||
|
Url = response.Url;
|
||||||
|
FileName = response.FileName;
|
||||||
|
Size = response.Size;
|
||||||
|
SizeName = response.SizeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
[PrimaryKey]
|
||||||
|
public string Id { get; set; }
|
||||||
|
[Indexed]
|
||||||
|
public string LoginId { get; set; }
|
||||||
|
public string Url { get; set; }
|
||||||
|
public string FileName { get; set; }
|
||||||
|
public string Size { get; set; }
|
||||||
|
public string SizeName { get; set; }
|
||||||
|
|
||||||
|
public Attachment ToAttachment()
|
||||||
|
{
|
||||||
|
return new Attachment(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,7 +22,10 @@ namespace Bit.App.Models.Data
|
||||||
Username = login.Username?.EncryptedString;
|
Username = login.Username?.EncryptedString;
|
||||||
Password = login.Password?.EncryptedString;
|
Password = login.Password?.EncryptedString;
|
||||||
Notes = login.Notes?.EncryptedString;
|
Notes = login.Notes?.EncryptedString;
|
||||||
|
Totp = login?.Notes?.EncryptedString;
|
||||||
Favorite = login.Favorite;
|
Favorite = login.Favorite;
|
||||||
|
Edit = login.Edit;
|
||||||
|
OrganizationUseTotp = login.OrganizationUseTotp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoginData(LoginResponse login, string userId)
|
public LoginData(LoginResponse login, string userId)
|
||||||
|
@ -36,8 +39,11 @@ namespace Bit.App.Models.Data
|
||||||
Username = login.Username;
|
Username = login.Username;
|
||||||
Password = login.Password;
|
Password = login.Password;
|
||||||
Notes = login.Notes;
|
Notes = login.Notes;
|
||||||
|
Totp = login.Totp;
|
||||||
Favorite = login.Favorite;
|
Favorite = login.Favorite;
|
||||||
RevisionDateTime = login.RevisionDate;
|
RevisionDateTime = login.RevisionDate;
|
||||||
|
Edit = login.Edit;
|
||||||
|
OrganizationUseTotp = login.OrganizationUseTotp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoginData(CipherResponse cipher, string userId)
|
public LoginData(CipherResponse cipher, string userId)
|
||||||
|
@ -58,7 +64,10 @@ namespace Bit.App.Models.Data
|
||||||
Username = data.Username;
|
Username = data.Username;
|
||||||
Password = data.Password;
|
Password = data.Password;
|
||||||
Notes = data.Notes;
|
Notes = data.Notes;
|
||||||
|
Totp = data.Totp;
|
||||||
Favorite = cipher.Favorite;
|
Favorite = cipher.Favorite;
|
||||||
|
Edit = cipher.Edit;
|
||||||
|
OrganizationUseTotp = cipher.OrganizationUseTotp;
|
||||||
RevisionDateTime = cipher.RevisionDate;
|
RevisionDateTime = cipher.RevisionDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +82,10 @@ namespace Bit.App.Models.Data
|
||||||
public string Username { get; set; }
|
public string Username { get; set; }
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
public string Notes { get; set; }
|
public string Notes { get; set; }
|
||||||
|
public string Totp { get; set; }
|
||||||
public bool Favorite { get; set; }
|
public bool Favorite { get; set; }
|
||||||
|
public bool Edit { get; set; }
|
||||||
|
public bool OrganizationUseTotp { get; set; }
|
||||||
public DateTime RevisionDateTime { get; set; } = DateTime.UtcNow;
|
public DateTime RevisionDateTime { get; set; } = DateTime.UtcNow;
|
||||||
|
|
||||||
public Login ToLogin()
|
public Login ToLogin()
|
||||||
|
|
|
@ -3,7 +3,7 @@ using Bit.App.Models.Api;
|
||||||
|
|
||||||
namespace Bit.App.Models
|
namespace Bit.App.Models
|
||||||
{
|
{
|
||||||
public class Folder : Cipher
|
public class Folder
|
||||||
{
|
{
|
||||||
public Folder()
|
public Folder()
|
||||||
{ }
|
{ }
|
||||||
|
@ -20,6 +20,9 @@ namespace Bit.App.Models
|
||||||
Name = response.Name != null ? new CipherString(response.Name) : null;
|
Name = response.Name != null ? new CipherString(response.Name) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string Id { get; set; }
|
||||||
|
public CipherString Name { get; set; }
|
||||||
|
|
||||||
public FolderRequest ToFolderRequest()
|
public FolderRequest ToFolderRequest()
|
||||||
{
|
{
|
||||||
return new FolderRequest(this);
|
return new FolderRequest(this);
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
using Bit.App.Models.Api;
|
using Bit.App.Models.Api;
|
||||||
using Bit.App.Models.Data;
|
using Bit.App.Models.Data;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Bit.App.Models
|
namespace Bit.App.Models
|
||||||
{
|
{
|
||||||
public class Login : Cipher
|
public class Login
|
||||||
{
|
{
|
||||||
public Login()
|
public Login()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
public Login(LoginData data)
|
public Login(LoginData data, IEnumerable<AttachmentData> attachments = null)
|
||||||
{
|
{
|
||||||
Id = data.Id;
|
Id = data.Id;
|
||||||
UserId = data.UserId;
|
UserId = data.UserId;
|
||||||
|
@ -19,7 +21,11 @@ namespace Bit.App.Models
|
||||||
Username = data.Username != null ? new CipherString(data.Username) : null;
|
Username = data.Username != null ? new CipherString(data.Username) : null;
|
||||||
Password = data.Password != null ? new CipherString(data.Password) : null;
|
Password = data.Password != null ? new CipherString(data.Password) : null;
|
||||||
Notes = data.Notes != null ? new CipherString(data.Notes) : null;
|
Notes = data.Notes != null ? new CipherString(data.Notes) : null;
|
||||||
|
Totp = data.Totp != null ? new CipherString(data.Totp) : null;
|
||||||
Favorite = data.Favorite;
|
Favorite = data.Favorite;
|
||||||
|
Edit = data.Edit;
|
||||||
|
OrganizationUseTotp = data.OrganizationUseTotp;
|
||||||
|
Attachments = attachments?.Select(a => new Attachment(a));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Login(LoginResponse response)
|
public Login(LoginResponse response)
|
||||||
|
@ -33,17 +39,27 @@ namespace Bit.App.Models
|
||||||
Username = response.Username != null ? new CipherString(response.Username) : null;
|
Username = response.Username != null ? new CipherString(response.Username) : null;
|
||||||
Password = response.Password != null ? new CipherString(response.Password) : null;
|
Password = response.Password != null ? new CipherString(response.Password) : null;
|
||||||
Notes = response.Notes != null ? new CipherString(response.Notes) : null;
|
Notes = response.Notes != null ? new CipherString(response.Notes) : null;
|
||||||
|
Totp = response.Totp != null ? new CipherString(response.Totp) : null;
|
||||||
Favorite = response.Favorite;
|
Favorite = response.Favorite;
|
||||||
|
Edit = response.Edit;
|
||||||
|
OrganizationUseTotp = response.OrganizationUseTotp;
|
||||||
|
Attachments = response.Attachments?.Select(a => new Attachment(a));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string Id { get; set; }
|
||||||
public string UserId { get; set; }
|
public string UserId { get; set; }
|
||||||
public string OrganizationId { get; set; }
|
public string OrganizationId { get; set; }
|
||||||
public string FolderId { get; set; }
|
public string FolderId { get; set; }
|
||||||
|
public CipherString Name { get; set; }
|
||||||
public CipherString Uri { get; set; }
|
public CipherString Uri { get; set; }
|
||||||
public CipherString Username { get; set; }
|
public CipherString Username { get; set; }
|
||||||
public CipherString Password { get; set; }
|
public CipherString Password { get; set; }
|
||||||
public CipherString Notes { get; set; }
|
public CipherString Notes { get; set; }
|
||||||
|
public CipherString Totp { get; set; }
|
||||||
public bool Favorite { get; set; }
|
public bool Favorite { get; set; }
|
||||||
|
public bool Edit { get; set; }
|
||||||
|
public bool OrganizationUseTotp { get; set; }
|
||||||
|
public IEnumerable<Attachment> Attachments { get; set; }
|
||||||
|
|
||||||
public LoginRequest ToLoginRequest()
|
public LoginRequest ToLoginRequest()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue