IVSession.cs 781 B

12345678910111213141516171819202122232425
  1. using System;
  2. namespace VCommon.VApplication
  3. {
  4. public interface IVSession
  5. {
  6. Guid? UserId { get; }
  7. Guid? TenantId { get; }
  8. void DemandAuth();
  9. public Guid GetUserId()
  10. {
  11. if (!UserId.HasValue) throw new VApplicationAuthException("Session.UserId is null! Probably, user is not logged in.", AuthReason.AuthRequired);
  12. return UserId.Value;
  13. }
  14. public Guid GetTenantId()
  15. {
  16. if (!TenantId.HasValue)
  17. throw new VApplicationAuthException("Session.TenantId is null! Possible problems: No user logged in or current logged in user in a host user (TenantId is always null for host users).", AuthReason.AuthRequired);
  18. return TenantId.Value;
  19. }
  20. }
  21. }