The next generation of the Teknik Services. Written in ASP.NET. https://www.teknik.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TeknikPrincipal.cs 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Security.Principal;
  5. using System.Web;
  6. using Teknik.Areas.Users.Models;
  7. using Teknik.Areas.Users.Utility;
  8. using Teknik.Data;
  9. using Teknik.Models;
  10. using Teknik.Utilities;
  11. namespace Teknik.Security
  12. {
  13. public class TeknikPrincipal : ITeknikPrincipal
  14. {
  15. private IIdentity _Identity;
  16. public IIdentity Identity
  17. {
  18. get
  19. {
  20. return this._Identity;
  21. }
  22. }
  23. private User m_Info = null;
  24. public User Info
  25. {
  26. get
  27. {
  28. if (m_Info == null && Identity != null && Identity.IsAuthenticated)
  29. {
  30. //TeknikEntities db = new TeknikEntities();
  31. //m_Info = UserHelper.GetUser(db, Identity.Name);
  32. }
  33. return m_Info;
  34. }
  35. }
  36. public TeknikPrincipal(string username)
  37. {
  38. this._Identity = new GenericIdentity(username, "Forms");
  39. }
  40. public bool IsInRole(string role)
  41. {
  42. return UserHelper.UserHasRoles(Info, role);
  43. }
  44. }
  45. }