1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-01 16:12:49 -05:00

record installation devices

This commit is contained in:
Kyle Spearrin
2019-03-19 00:39:03 -04:00
parent 11fafa4a92
commit 01a293cf76
15 changed files with 255 additions and 36 deletions

View File

@ -8,6 +8,7 @@ namespace Bit.Core.Models.Api
{
public string UserId { get; set; }
public string OrganizationId { get; set; }
public string DeviceId { get; set; }
public string Identifier { get; set; }
[Required]
public PushType? Type { get; set; }

View File

@ -0,0 +1,36 @@
using System;
using Microsoft.WindowsAzure.Storage.Table;
namespace Bit.Core.Models.Data
{
public class InstallationDeviceEntity : TableEntity
{
public InstallationDeviceEntity() { }
public InstallationDeviceEntity(Guid installationId, Guid deviceId)
{
PartitionKey = installationId.ToString();
RowKey = deviceId.ToString();
}
public InstallationDeviceEntity(string prefixedDeviceId)
{
var parts = prefixedDeviceId.Split("_");
if(parts.Length < 2)
{
throw new ArgumentException("Not enough parts.");
}
if(!Guid.TryParse(parts[0], out var installationId) || !Guid.TryParse(parts[1], out var deviceId))
{
throw new ArgumentException("Could not parse parts.");
}
PartitionKey = parts[0];
RowKey = parts[1];
}
public static bool IsInstallationDeviceId(string deviceId)
{
return deviceId != null && deviceId.Length == 73 && deviceId[36] == '_';
}
}
}