summaryrefslogtreecommitdiff
path: root/Project-Unite/Global.asax.cs
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-05-11 10:14:48 -0400
committerMichael <[email protected]>2017-05-11 10:14:48 -0400
commitdbce55459fae3568c3cd69562b5fe37bc7493d1c (patch)
tree8afedb1f12cef77acd4bf436d2b6e7f3b01eb96b /Project-Unite/Global.asax.cs
parent7e0dfbb778197ea4dc8205711ea96d87d24d1c95 (diff)
downloadproject-unite-dbce55459fae3568c3cd69562b5fe37bc7493d1c.tar.gz
project-unite-dbce55459fae3568c3cd69562b5fe37bc7493d1c.tar.bz2
project-unite-dbce55459fae3568c3cd69562b5fe37bc7493d1c.zip
Jesus.
*looks at the atmosphere with major thoights of the mess he has created*
Diffstat (limited to 'Project-Unite/Global.asax.cs')
-rw-r--r--Project-Unite/Global.asax.cs60
1 files changed, 31 insertions, 29 deletions
diff --git a/Project-Unite/Global.asax.cs b/Project-Unite/Global.asax.cs
index 41208ad..79df7eb 100644
--- a/Project-Unite/Global.asax.cs
+++ b/Project-Unite/Global.asax.cs
@@ -37,6 +37,23 @@ namespace Project_Unite
migrator.Update();
+
+ var addr = HttpContext.Current.Request.UserHostAddress;
+ var db = new ApplicationDbContext();
+ var ip = db.BannedIPs.FirstOrDefault(i => i.Address == addr);
+ if (ip != null)
+ {
+ //The user is banned. Anally rape their ability to get on here.
+ this.Response.StatusCode = 403;
+ this.CompleteRequest();
+ return;
+ }
+
+
+ }
+
+ protected void Application_EndRequest(object s, EventArgs e)
+ {
string raw_url = Request.Url.ToString().Replace("//", "\\\\");
string[] split = raw_url.Split(new[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
@@ -44,7 +61,7 @@ namespace Project_Unite
string actionname = "Index";
string controllername = "Home";
- if(split.Length > 1)
+ if (split.Length > 1)
{
controllername = split[1];
if (split.Length == 3)
@@ -57,14 +74,14 @@ namespace Project_Unite
var mod = ctl.GetCustomAttributes(false).FirstOrDefault(x => x is RequiresModerator);
var dev = ctl.GetCustomAttributes(false).FirstOrDefault(x => x is RequiresDeveloper);
- bool fail = false;
+ bool? fail = false;
if (adm != null)
- fail = (bool)!User.Identity?.IsAdmin();
+ fail = !User?.Identity?.IsAdmin();
if (mod != null)
- fail = (bool)!User.Identity?.IsModerator();
+ fail = !User?.Identity?.IsModerator();
if (dev != null)
- fail = (bool)!User.Identity?.IsDeveloper();
+ fail = !User?.Identity?.IsDeveloper();
var act = ctl.GetMethods(BindingFlags.Public | BindingFlags.Instance).FirstOrDefault(x => x.Name == actionname);
@@ -75,38 +92,23 @@ namespace Project_Unite
bool? fail2 = true;
if (adm != null)
- fail2 = User.Identity?.IsAdmin();
- if (mod != null)
- fail2 = User.Identity?.IsModerator();
+ fail2 = User?.Identity?.IsAdmin();
+ if (mod != null)
+ fail2 = User?.Identity?.IsModerator();
if (dev != null)
- fail2 = User.Identity?.IsDeveloper();
+ fail2 = User?.Identity?.IsDeveloper();
- if (fail2 != null)
- fail = fail || !(bool)fail2;
+ bool realfail = (fail == null) ? true : (bool)fail;
+ bool realfail2 = (fail2 == null) ? true : (bool)fail2;
- if (fail == true)
+ realfail = realfail || !realfail2;
+
+ if (realfail == true)
{
string url = "http://" + this.Request.Url.Host.Replace("http://", "").Replace("https://", "") + "/Home/AccessDenied";
Response.Redirect(url, true);
return;
}
-
- var addr = HttpContext.Current.Request.UserHostAddress;
- var db = new ApplicationDbContext();
- var ip = db.BannedIPs.FirstOrDefault(i => i.Address == addr);
- if (ip != null)
- {
- //The user is banned. Anally rape their ability to get on here.
- this.Response.StatusCode = 403;
- this.CompleteRequest();
- return;
- }
-
-
- }
-
- protected void Application_EndRequest(object s, EventArgs e)
- {
var db = new ApplicationDbContext();
if (Request.IsAuthenticated)
{