diff options
| author | Michael <[email protected]> | 2017-05-09 16:47:06 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-05-09 16:47:06 -0400 |
| commit | 3e6500f958b733591df79d76c5ffa9862d2b1d59 (patch) | |
| tree | 06fc24d84d0114f3cac9b8b88cafcb790175f821 /Project-Unite | |
| parent | b946c99fa65c4af18812d4f6bb41837ecc3b0c98 (diff) | |
| download | project-unite-3e6500f958b733591df79d76c5ffa9862d2b1d59.tar.gz project-unite-3e6500f958b733591df79d76c5ffa9862d2b1d59.tar.bz2 project-unite-3e6500f958b733591df79d76c5ffa9862d2b1d59.zip | |
Fix various bugs with permission backend.
Diffstat (limited to 'Project-Unite')
| -rw-r--r-- | Project-Unite/Global.asax.cs | 56 |
1 files changed, 33 insertions, 23 deletions
diff --git a/Project-Unite/Global.asax.cs b/Project-Unite/Global.asax.cs index 0feb04e..ffc958e 100644 --- a/Project-Unite/Global.asax.cs +++ b/Project-Unite/Global.asax.cs @@ -73,13 +73,17 @@ namespace Project_Unite mod = act.GetCustomAttributes(false).FirstOrDefault(x => x is RequiresModerator); dev = act.GetCustomAttributes(false).FirstOrDefault(x => x is RequiresDeveloper); + bool? fail2 = false; + if (adm != null) - fail = fail || (bool)!User.Identity?.IsAdmin(); - if (mod != null) - fail = fail || (bool)!User.Identity?.IsModerator(); + fail2 = User.Identity?.IsAdmin(); + if (mod != null) + fail2 = User.Identity?.IsModerator(); if (dev != null) - fail = fail || (bool)!User.Identity?.IsDeveloper(); + fail2 = User.Identity?.IsDeveloper(); + if (fail2 != null) + fail = fail || !(bool)fail2; if (fail == true) { @@ -105,18 +109,20 @@ namespace Project_Unite protected void Application_EndRequest(object s, EventArgs e) { var db = new ApplicationDbContext(); - if (!string.IsNullOrEmpty(User.Identity.Name)) + if (Request.IsAuthenticated) { - //Check for a username ban. - var usr = db.Users.First(x => x.UserName == User.Identity.Name); - var banned = usr.IsBanned; - if (banned == true) + if (!string.IsNullOrEmpty(User.Identity.Name)) { - //The user is banned. Anally rape their ability to get on here. - this.Response.StatusCode = 200; - this.Response.ContentType = "plaintext"; - this.Response.ClearContent(); - this.Response.Output.Write($@"Greetings from the ShiftOS administration team, {ACL.UserNameRaw(User.Identity.GetUserId())}. + //Check for a username ban. + var usr = db.Users.First(x => x.UserName == User.Identity.Name); + var banned = usr.IsBanned; + if (banned == true) + { + //The user is banned. Anally rape their ability to get on here. + this.Response.StatusCode = 200; + this.Response.ContentType = "plaintext"; + this.Response.ClearContent(); + this.Response.Output.Write($@"Greetings from the ShiftOS administration team, {ACL.UserNameRaw(User.Identity.GetUserId())}. If you are seeing this page, it means two things: @@ -148,17 +154,21 @@ We also reserve the right to purge your data after 2 months of a permanent ban. so do not cry to us when you find out you can't log in because your account got anhilated by the automatic purge system. - Michael VanOverbeek, on behalf of the ShiftOS staff. Play fair."); - this.CompleteRequest(); - return; - - } - if (usr.LastKnownIPAddress != Request.UserHostAddress) - { - usr.LastKnownIPAddress = Request.UserHostAddress; - db.SaveChanges(); + this.CompleteRequest(); + return; + + } + if (usr.LastKnownIPAddress != Request.UserHostAddress) + { + usr.LastKnownIPAddress = Request.UserHostAddress; + db.SaveChanges(); + } } + CompleteRequest(); + return; } - + CompleteRequest(); + } } } |
