1
0
mirror of https://github.com/bitwarden/server.git synced 2024-12-02 13:53:23 +01:00
bitwarden-server/src/Core/CurrentContext.cs

37 lines
1.1 KiB
C#
Raw Normal View History

2015-12-09 04:57:38 +01:00
using System;
using System.Collections.Generic;
using System.Linq;
2017-03-09 03:45:08 +01:00
using Bit.Core.Models.Table;
using Bit.Core.Enums;
2015-12-09 04:57:38 +01:00
namespace Bit.Core
{
public class CurrentContext
{
public virtual User User { get; set; }
public virtual string DeviceIdentifier { get; set; }
public virtual List<CurrentContentOrganization> Organizations { get; set; } = new List<CurrentContentOrganization>();
public virtual Guid? InstallationId { get; set; }
public bool OrganizationUser(Guid orgId)
{
return Organizations.Any(o => o.Id == orgId);
}
public bool OrganizationAdmin(Guid orgId)
{
return Organizations.Any(o => o.Id == orgId &&
(o.Type == OrganizationUserType.Owner || o.Type == OrganizationUserType.Admin));
}
public bool OrganizationOwner(Guid orgId)
{
return Organizations.Any(o => o.Id == orgId && o.Type == OrganizationUserType.Owner);
}
public class CurrentContentOrganization
{
public Guid Id { get; set; }
public OrganizationUserType Type { get; set; }
}
2015-12-09 04:57:38 +01:00
}
}