fix accidental improper name for login ClientId

added label field to InputInfo
added logout button
revert graph color
This commit is contained in:
RaidMax
2018-04-05 17:50:04 -05:00
parent 6d8d021b16
commit b6f490be9c
7 changed files with 34 additions and 21 deletions

View File

@ -9,16 +9,16 @@ namespace WebfrontCore.Controllers
public class AccountController : BaseController
{
[HttpGet]
public async Task<IActionResult> Login(int userId, string password)
public async Task<IActionResult> LoginAsync(int clientId, string password)
{
if (userId == 0 || string.IsNullOrEmpty(password))
if (clientId == 0 || string.IsNullOrEmpty(password))
{
return Unauthorized();
}
try
{
var client = IW4MAdmin.Program.ServerManager.PrivilegedClients[userId];
var client = IW4MAdmin.Program.ServerManager.PrivilegedClients[clientId];
string[] hashedPassword = await Task.FromResult(SharedLibrary.Helpers.Hashing.Hash(password, client.PasswordSalt));
if (hashedPassword[0] == client.Password)
@ -51,5 +51,12 @@ namespace WebfrontCore.Controllers
return Unauthorized();
}
[HttpGet]
public async Task<IActionResult> LogoutAsync()
{
await HttpContext.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
return RedirectToAction("Index", "Home");
}
}
}

View File

@ -82,23 +82,25 @@ namespace WebfrontCore.Controllers
{
new InputInfo()
{
Name = "User ID"
Name = "clientId",
Label = "Client ID"
},
new InputInfo()
{
Name = "Password",
Label ="Password",
Type = "password",
}
},
Action = "Login"
Action = "LoginAsync"
};
return View("_ActionForm", login);
}
public IActionResult Login(int userId, string password)
public async Task<IActionResult> LoginAsync(int clientId, string password)
{
return RedirectToAction("Login", "Account", new { userId, password });
return await Task.FromResult(RedirectToAction("LoginAsync", "Account", new { clientId, password }));
}
}
}