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.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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.Models;
  9. using Teknik.Utilities;
  10. namespace Teknik.Security
  11. {
  12. public class TeknikPrincipal : ITeknikPrincipal
  13. {
  14. private IIdentity _Identity;
  15. public IIdentity Identity
  16. {
  17. get
  18. {
  19. return this._Identity;
  20. }
  21. }
  22. private User m_Info;
  23. public User Info
  24. {
  25. get
  26. {
  27. if (m_Info == null && Identity != null && Identity.IsAuthenticated)
  28. {
  29. TeknikEntities db = new TeknikEntities();
  30. m_Info = UserHelper.GetUser(db, Identity.Name);
  31. }
  32. return m_Info;
  33. }
  34. }
  35. public TeknikPrincipal(string username)
  36. {
  37. this._Identity = new GenericIdentity(username, "Forms");
  38. }
  39. public bool IsInRole(string role)
  40. {
  41. return UserHelper.UserHasRoles(Info, role);
  42. }
  43. }
  44. }