Advertisement
Guest User

Untitled

a guest
Aug 17th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. <caching>
  2. <outputCacheSettings>
  3. <outputCacheProfiles>
  4. <add name ="Long" duration="300"/>
  5. <add name ="Short" duration="3"/>
  6. </outputCacheProfiles>
  7. </outputCacheSettings>
  8. </caching>
  9.  
  10. protected override bool AuthorizeCore(HttpContextBase httpContext)
  11. {
  12.  
  13.  
  14. User currentUser = (User)httpContext.Session["CurrentUser"];
  15.  
  16. if (currentUser == null)
  17. {
  18. return false;
  19. }
  20.  
  21. if (currentUser.Role == RolesEnum.User && _role == RolesEnum.Admin)
  22. {
  23. return false;
  24. }
  25.  
  26. return true;
  27. }
  28.  
  29. [HttpPost]
  30. public ActionResult Login(string username, string password)
  31. {
  32.  
  33.  
  34. User login = db.Users.Where(p => p.Username == username && p.Password == password).FirstOrDefault();
  35.  
  36.  
  37. if (login == null)
  38. {
  39. return View();
  40. }
  41.  
  42. Session.Add("CurrentUser", login);
  43. return RedirectToAction("Index", "Projects", null);
  44.  
  45. }
  46.  
  47. [CustomAuthorize]
  48. [OutputCache(CacheProfile = "Long")]
  49. public ActionResult Index(string currentFilter, string searchTerm, int? page, string searchContainingText)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement