2015-12-08 22:57:38 -05:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
2017-03-08 21:45:08 -05:00
|
|
|
|
using Bit.Core.Models.Table;
|
2017-04-05 16:13:40 -04:00
|
|
|
|
using Bit.Core.Enums;
|
2015-12-08 22:57:38 -05:00
|
|
|
|
|
|
|
|
|
|
namespace Bit.Core
|
|
|
|
|
|
{
|
|
|
|
|
|
public class CurrentContext
|
|
|
|
|
|
{
|
|
|
|
|
|
public virtual User User { get; set; }
|
2016-08-06 02:29:15 -04:00
|
|
|
|
public virtual string DeviceIdentifier { get; set; }
|
2017-04-05 16:13:40 -04:00
|
|
|
|
public virtual List<CurrentContentOrganization> Organizations { get; set; } = new List<CurrentContentOrganization>();
|
|
|
|
|
|
|
|
|
|
|
|
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-08 22:57:38 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|