Git Repository Public Repository

CPE_learningsite

URLs

Copy to Clipboard

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 2177bd ... vs 831ee4 ... for CPE/CPE.App/CPE.App.Web/Controllers/IndexController.cs

Diff revisions: vs.
  @@ -27,14 +27,28 @@
27 27 return false;
28 28 }
29 29
30 + private bool IsAdmin(string login, string password)
31 + {
32 + return Database.Users.Any(t => t.IsAdmin && t.Login == login && t.Password == password);
33 + }
34 +
35 + private bool IsAdmin(string password)
36 + {
37 + return Database.Users.Any(t => t.IsAdmin && t.Password == password);
38 + }
39 +
30 40 // GET: Index
31 41 [HttpGet]
32 42 public ActionResult Index(int? year) {
33 43 if(Request.Cookies["allowed"] == null && !IsLocal())
34 44 return Redirect("http://www.cpeonline.com/webcasts");
35 - string systemPassword = ConfigurationManager.AppSettings["password"];
36 - if(Request.Cookies["allowed"] != null && (Request.Cookies["allowed"].Value != systemPassword))
45 +
46 + //string systemPassword = ConfigurationManager.AppSettings["password"];
47 + if (Request.Cookies["allowed"] != null && !IsAdmin(Request.Cookies["allowed"].Value))
48 + {
37 49 return Redirect("http://www.cpeonline.com/webcasts");
50 + }
51 +
38 52 DateTime now = DateTime.UtcNow;
39 53
40 54 if(!year.HasValue) {
  @@ -440,10 +454,10 @@
440 454 login = login?.Trim();
441 455 passcode = passcode?.Trim();
442 456
443 - string systemPassword = ConfigurationManager.AppSettings["password"];
444 - if(login == ConfigurationManager.AppSettings["login"] & passcode == systemPassword) {
457 + // string systemPassword = ConfigurationManager.AppSettings["password"];
458 + if(IsAdmin(login, passcode)) {
445 459 var reportingCookie = new HttpCookie("allowed") {
446 - Value = systemPassword,
460 + Value = passcode,
447 461 Expires = DateTime.UtcNow.AddDays(1)
448 462 };
449 463 Response.Cookies.Add(reportingCookie);
  @@ -470,8 +484,8 @@
470 484 public ActionResult Elucidat() {
471 485 if(Request.Cookies["allowed"] == null && !IsLocal())
472 486 return Redirect("http://www.cpeonline.com/webcasts");
473 - string systemPassword = ConfigurationManager.AppSettings["password"];
474 - if(Request.Cookies["allowed"] != null && (Request.Cookies["allowed"].Value != systemPassword))
487 + // string systemPassword = ConfigurationManager.AppSettings["password"];
488 + if(Request.Cookies["allowed"] != null && (!IsAdmin(Request.Cookies["allowed"].Value)))
475 489 return Redirect("http://www.cpeonline.com/webcasts");
476 490 DateTime now = DateTime.UtcNow;
477 491