mirror of
https://github.com/lempamo/Project-Unite.git
synced 2025-01-22 17:22:15 +00:00
Fix various bugs with permission backend.
This commit is contained in:
parent
b946c99fa6
commit
3e6500f958
1 changed files with 34 additions and 24 deletions
|
@ -73,13 +73,17 @@ protected void Application_BeginRequest(object sender, EventArgs e)
|
||||||
mod = act.GetCustomAttributes(false).FirstOrDefault(x => x is RequiresModerator);
|
mod = act.GetCustomAttributes(false).FirstOrDefault(x => x is RequiresModerator);
|
||||||
dev = act.GetCustomAttributes(false).FirstOrDefault(x => x is RequiresDeveloper);
|
dev = act.GetCustomAttributes(false).FirstOrDefault(x => x is RequiresDeveloper);
|
||||||
|
|
||||||
if (adm != null)
|
bool? fail2 = false;
|
||||||
fail = fail || (bool)!User.Identity?.IsAdmin();
|
|
||||||
if (mod != null)
|
|
||||||
fail = fail || (bool)!User.Identity?.IsModerator();
|
|
||||||
if (dev != null)
|
|
||||||
fail = fail || (bool)!User.Identity?.IsDeveloper();
|
|
||||||
|
|
||||||
|
if (adm != null)
|
||||||
|
fail2 = User.Identity?.IsAdmin();
|
||||||
|
if (mod != null)
|
||||||
|
fail2 = User.Identity?.IsModerator();
|
||||||
|
if (dev != null)
|
||||||
|
fail2 = User.Identity?.IsDeveloper();
|
||||||
|
|
||||||
|
if (fail2 != null)
|
||||||
|
fail = fail || !(bool)fail2;
|
||||||
|
|
||||||
if (fail == true)
|
if (fail == true)
|
||||||
{
|
{
|
||||||
|
@ -105,18 +109,20 @@ protected void Application_BeginRequest(object sender, EventArgs e)
|
||||||
protected void Application_EndRequest(object s, EventArgs e)
|
protected void Application_EndRequest(object s, EventArgs e)
|
||||||
{
|
{
|
||||||
var db = new ApplicationDbContext();
|
var db = new ApplicationDbContext();
|
||||||
if (!string.IsNullOrEmpty(User.Identity.Name))
|
if (Request.IsAuthenticated)
|
||||||
{
|
{
|
||||||
//Check for a username ban.
|
if (!string.IsNullOrEmpty(User.Identity.Name))
|
||||||
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.
|
//Check for a username ban.
|
||||||
this.Response.StatusCode = 200;
|
var usr = db.Users.First(x => x.UserName == User.Identity.Name);
|
||||||
this.Response.ContentType = "plaintext";
|
var banned = usr.IsBanned;
|
||||||
this.Response.ClearContent();
|
if (banned == true)
|
||||||
this.Response.Output.Write($@"Greetings from the ShiftOS administration team, {ACL.UserNameRaw(User.Identity.GetUserId())}.
|
{
|
||||||
|
//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:
|
If you are seeing this page, it means two things:
|
||||||
|
|
||||||
|
@ -148,17 +154,21 @@ you will be IP-banned and this screen won't be as friendly to you.
|
||||||
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.
|
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.");
|
- Michael VanOverbeek, on behalf of the ShiftOS staff. Play fair.");
|
||||||
this.CompleteRequest();
|
this.CompleteRequest();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
if (usr.LastKnownIPAddress != Request.UserHostAddress)
|
||||||
|
{
|
||||||
|
usr.LastKnownIPAddress = Request.UserHostAddress;
|
||||||
|
db.SaveChanges();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (usr.LastKnownIPAddress != Request.UserHostAddress)
|
CompleteRequest();
|
||||||
{
|
return;
|
||||||
usr.LastKnownIPAddress = Request.UserHostAddress;
|
|
||||||
db.SaveChanges();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
CompleteRequest();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue