mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 15:42:48 -05:00
log user events
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
using Bit.Core.Enums;
|
||||
using System;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Table;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
@ -8,22 +9,23 @@ namespace Bit.Core.Models.Data
|
||||
{
|
||||
public CipherEvent(Cipher cipher, EventType type)
|
||||
{
|
||||
if(cipher.OrganizationId.HasValue)
|
||||
{
|
||||
PartitionKey = $"OrganizationId={cipher.OrganizationId.Value}";
|
||||
}
|
||||
else
|
||||
{
|
||||
PartitionKey = $"UserId={cipher.UserId.Value}";
|
||||
}
|
||||
|
||||
RowKey = string.Format("Date={0}__CipherId={1}__Type={2}",
|
||||
CoreHelpers.DateTimeToTableStorageKey(), cipher.Id, type);
|
||||
|
||||
OrganizationId = cipher.OrganizationId;
|
||||
UserId = cipher.UserId;
|
||||
CipherId = cipher.Id;
|
||||
Type = type;
|
||||
Type = (int)type;
|
||||
|
||||
Timestamp = DateTime.UtcNow;
|
||||
if(OrganizationId.HasValue)
|
||||
{
|
||||
PartitionKey = $"OrganizationId={OrganizationId}";
|
||||
}
|
||||
else
|
||||
{
|
||||
PartitionKey = $"UserId={UserId}";
|
||||
}
|
||||
|
||||
RowKey = string.Format("Date={0}__CipherId={1}__Type={2}",
|
||||
CoreHelpers.DateTimeToTableStorageKey(Timestamp.DateTime), CipherId, Type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ namespace Bit.Core.Models.Data
|
||||
{
|
||||
public class EventTableEntity : TableEntity
|
||||
{
|
||||
public EventType Type { get; set; }
|
||||
public int Type { get; set; }
|
||||
public Guid? UserId { get; set; }
|
||||
public Guid? OrganizationId { get; set; }
|
||||
public Guid? CipherId { get; set; }
|
||||
|
@ -8,23 +8,25 @@ namespace Bit.Core.Models.Data
|
||||
{
|
||||
public OrganizationEvent(Guid organizationId, EventType type)
|
||||
{
|
||||
PartitionKey = $"OrganizationId={organizationId}";
|
||||
RowKey = string.Format("Date={0}__Type={1}",
|
||||
CoreHelpers.DateTimeToTableStorageKey(), type);
|
||||
|
||||
OrganizationId = organizationId;
|
||||
Type = type;
|
||||
Type = (int)type;
|
||||
|
||||
Timestamp = DateTime.UtcNow;
|
||||
PartitionKey = $"OrganizationId={OrganizationId}";
|
||||
RowKey = string.Format("Date={0}__Type={1}",
|
||||
CoreHelpers.DateTimeToTableStorageKey(Timestamp.DateTime), Type);
|
||||
}
|
||||
|
||||
public OrganizationEvent(Guid organizationId, Guid userId, EventType type)
|
||||
{
|
||||
PartitionKey = $"OrganizationId={organizationId}";
|
||||
RowKey = string.Format("Date={0}__UserId={1}__Type={2}",
|
||||
CoreHelpers.DateTimeToTableStorageKey(), userId, type);
|
||||
|
||||
OrganizationId = organizationId;
|
||||
UserId = userId;
|
||||
Type = type;
|
||||
Type = (int)type;
|
||||
|
||||
Timestamp = DateTime.UtcNow;
|
||||
PartitionKey = $"OrganizationId={OrganizationId}";
|
||||
RowKey = string.Format("Date={0}__UserId={1}__Type={2}",
|
||||
CoreHelpers.DateTimeToTableStorageKey(Timestamp.DateTime), UserId, Type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,23 +8,25 @@ namespace Bit.Core.Models.Data
|
||||
{
|
||||
public UserEvent(Guid userId, EventType type)
|
||||
{
|
||||
PartitionKey = $"UserId={userId}";
|
||||
RowKey = string.Format("Date={0}__Type={1}",
|
||||
CoreHelpers.DateTimeToTableStorageKey(), type);
|
||||
|
||||
UserId = userId;
|
||||
Type = type;
|
||||
Type = (int)type;
|
||||
|
||||
Timestamp = DateTime.UtcNow;
|
||||
PartitionKey = $"UserId={UserId}";
|
||||
RowKey = string.Format("Date={0}__Type={1}",
|
||||
CoreHelpers.DateTimeToTableStorageKey(Timestamp.DateTime), Type);
|
||||
}
|
||||
|
||||
public UserEvent(Guid userId, Guid organizationId, EventType type)
|
||||
{
|
||||
PartitionKey = $"OrganizationId={organizationId}";
|
||||
RowKey = string.Format("Date={0}__UserId={1}__Type={2}",
|
||||
CoreHelpers.DateTimeToTableStorageKey(), userId, type);
|
||||
|
||||
OrganizationId = organizationId;
|
||||
UserId = userId;
|
||||
Type = type;
|
||||
Type = (int)type;
|
||||
|
||||
Timestamp = DateTime.UtcNow;
|
||||
PartitionKey = $"OrganizationId={OrganizationId}";
|
||||
RowKey = string.Format("Date={0}__UserId={1}__Type={2}",
|
||||
CoreHelpers.DateTimeToTableStorageKey(Timestamp.DateTime), UserId, Type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user