public async Task <HttpResponseMessage> Dashboard() { if (Request.RequestUri.Query != null && Request.RequestUri.Query.Contains("logout")) { var file = GetFile("login.html"); securityService.Logout(file); return(file); } if (securityService.CheckAuthorised(Request)) { return(GetFile("index.html")); } else { var formData = await Request.Content.ReadAsFormDataAsync(); if (formData != null && securityService.HashPassword(formData["password"]) == serverService.Config.AdminPassword) { var file = GetFile("index.html"); securityService.Login(file); return(file); } else { return(GetFile("login.html")); } } }
public async Task <IActionResult> Dashboard([FromForm] string password) { if (password != null && securityService.HashPassword(password) == serverConfig.AdminPassword) { await MakeUserAuthenticated(); } return(Redirect("Dashboard")); }
public void AdminPassword([FromBody] string password) { var oldPassword = serverConfig.AdminPassword; if (string.IsNullOrEmpty(password)) { password = string.Empty; } if (oldPassword != password) { serverConfig.AdminPassword = securityService.HashPassword(password); configService.SaveConfig(serverConfig); } }
public IActionResult AdminPassword([FromBody] string password) { var oldPassword = serverConfig.AdminPassword; if (string.IsNullOrEmpty(password)) { password = null; } if (oldPassword != password) { serverConfig.AdminPassword = securityService.HashPassword(password); configService.SaveConfig(serverConfig); } return(new NoContentResult()); }