mirror of
https://github.com/bitwarden/mobile
synced 2026-01-07 02:53:56 +00:00
set org keys on login and decrypt org ciphers
This commit is contained in:
14
src/App/Models/Api/Response/ProfileOrganizationResponse.cs
Normal file
14
src/App/Models/Api/Response/ProfileOrganizationResponse.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using Bit.App.Enums;
|
||||
|
||||
namespace Bit.App.Models.Api
|
||||
{
|
||||
public class ProfileOrganizationResponseModel
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Key { get; set; }
|
||||
public OrganizationUserStatusType Status { get; set; }
|
||||
public OrganizationUserType Type { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace Bit.App.Models.Api
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Bit.App.Models.Api
|
||||
{
|
||||
public class ProfileResponse
|
||||
{
|
||||
@@ -8,5 +10,6 @@
|
||||
public string MasterPasswordHint { get; set; }
|
||||
public string Culture { get; set; }
|
||||
public bool TwoFactorEnabled { get; set; }
|
||||
public IEnumerable<ProfileOrganizationResponseModel> Organizations { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,12 +102,19 @@ namespace Bit.App.Models
|
||||
public byte[] CipherTextBytes => Convert.FromBase64String(CipherText);
|
||||
public byte[] MacBytes => Mac == null ? null : Convert.FromBase64String(Mac);
|
||||
|
||||
public string Decrypt()
|
||||
public string Decrypt(string orgId = null)
|
||||
{
|
||||
if(_decryptedValue == null)
|
||||
{
|
||||
var cryptoService = Resolver.Resolve<ICryptoService>();
|
||||
_decryptedValue = cryptoService.Decrypt(this);
|
||||
if(!string.IsNullOrWhiteSpace(orgId))
|
||||
{
|
||||
_decryptedValue = cryptoService.Decrypt(this, cryptoService.GetOrgKey(orgId));
|
||||
}
|
||||
else
|
||||
{
|
||||
_decryptedValue = cryptoService.Decrypt(this);
|
||||
}
|
||||
}
|
||||
|
||||
return _decryptedValue;
|
||||
|
||||
@@ -12,10 +12,10 @@ namespace Bit.App.Models.Page
|
||||
{
|
||||
Id = login.Id;
|
||||
FolderId = login.FolderId;
|
||||
Name = login.Name?.Decrypt();
|
||||
Username = login.Username?.Decrypt() ?? " ";
|
||||
Password = new Lazy<string>(() => login.Password?.Decrypt());
|
||||
Uri = new Lazy<string>(() => login.Uri?.Decrypt());
|
||||
Name = login.Name?.Decrypt(login.OrganizationId);
|
||||
Username = login.Username?.Decrypt(login.OrganizationId) ?? " ";
|
||||
Password = new Lazy<string>(() => login.Password?.Decrypt(login.OrganizationId));
|
||||
Uri = new Lazy<string>(() => login.Uri?.Decrypt(login.OrganizationId));
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
|
||||
@@ -171,11 +171,11 @@ namespace Bit.App.Models.Page
|
||||
|
||||
public void Update(Login login)
|
||||
{
|
||||
Name = login.Name?.Decrypt();
|
||||
Username = login.Username?.Decrypt();
|
||||
Password = login.Password?.Decrypt();
|
||||
Uri = login.Uri?.Decrypt();
|
||||
Notes = login.Notes?.Decrypt();
|
||||
Name = login.Name?.Decrypt(login.OrganizationId);
|
||||
Username = login.Username?.Decrypt(login.OrganizationId);
|
||||
Password = login.Password?.Decrypt(login.OrganizationId);
|
||||
Uri = login.Uri?.Decrypt(login.OrganizationId);
|
||||
Notes = login.Notes?.Decrypt(login.OrganizationId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user