mirror of
https://github.com/Caraxi/mare.server.git
synced 2025-12-13 21:04:15 +01:00
adjustments to auth
This commit is contained in:
parent
99cf46875b
commit
4dade47819
1 changed files with 13 additions and 3 deletions
|
|
@ -45,13 +45,23 @@ public class JwtController : Controller
|
|||
if (string.IsNullOrEmpty(auth)) return BadRequest("No Authkey");
|
||||
if (string.IsNullOrEmpty(charaIdent)) return BadRequest("No CharaIdent");
|
||||
|
||||
var isBanned = await _mareDbContext.BannedUsers.AsNoTracking().AnyAsync(u => u.CharacterIdentification == charaIdent).ConfigureAwait(false);
|
||||
if (isBanned) return Unauthorized("Your character is banned from using the service.");
|
||||
|
||||
var ip = _accessor.GetIpAddress();
|
||||
|
||||
var authResult = await _secretKeyAuthenticatorService.AuthorizeAsync(ip, auth);
|
||||
|
||||
var isBanned = await _mareDbContext.BannedUsers.AsNoTracking().AnyAsync(u => u.CharacterIdentification == charaIdent).ConfigureAwait(false);
|
||||
if (isBanned)
|
||||
{
|
||||
var authToBan = _mareDbContext.Auth.SingleOrDefault(a => a.UserUID == authResult.Uid);
|
||||
if (authToBan != null)
|
||||
{
|
||||
authToBan.IsBanned = true;
|
||||
await _mareDbContext.SaveChangesAsync().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
return Unauthorized("Your character is banned from using the service.");
|
||||
}
|
||||
|
||||
if (!authResult.Success && !authResult.TempBan) return Unauthorized("The provided secret key is invalid. Verify your accounts existence and/or recover the secret key.");
|
||||
if (!authResult.Success && authResult.TempBan) return Unauthorized("You are temporarily banned. Try connecting again in 5 minutes.");
|
||||
if (authResult.Permaban)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue