private string Authorize(DynamicDictionary _parameters) { User user; string result = AuthHelper.Authorize(Request, out user); return(result); }
public async Task <IActionResult> Authorization(string login, string password) { using (var auth = new AuthHelper(Configuration["ConnectionStrings:database"])) { return(Ok(await auth.Authorize(login, password))); } }
private BaseResponse Authorize( DynamicDictionary _parameters) { User user; BaseResponse response = AuthHelper.Authorize(Request, out user); return(response); }
public string HandleLoginPost(DynamicDictionary _parameters) { LoginRequest jLoginRequest; using (StreamReader sr = new StreamReader(Request.Body)) { string json = sr.ReadToEnd(); jLoginRequest = JsonConvert.DeserializeObject <LoginRequest>(json); } if (jLoginRequest != null) { TGUser user; LoginResult jResult = AuthHelper.Authorize(m_Manager, jLoginRequest.Username, jLoginRequest.Password, out user); return(JsonConvert.SerializeObject(jResult)); } return(null); }
private string HandleChangePassword(DynamicDictionary _parameters) { string currentPassword = Request.Form["currentpassword"]; string newPassword = Request.Form["newpassword"]; string username = Request.Headers["Username"].First(); User user = null; AuthHelper.Authorize(username, currentPassword, out user); if (user != null) { TGUserPassword up = TGUserPassword.GetNew(user.Guid, user.Username, newPassword); HydrantWikiManager hwm = new HydrantWikiManager(); hwm.Persist(up); return(@"{ ""Result"":""Success"" }");; } return(@"{ ""Result"":""Failure"" }"); }
public LoginModule() { Get["/login"] = _parameters => { return(View["login.sshtml"]); }; Post["/login"] = _parameters => { User user; string username = Request.Headers["Username"].First(); string password = Request.Headers["Password"].First(); string result = AuthHelper.Authorize(username, password, out user); Response response; if (user != null) { response = this.LoginWithoutRedirect(user.Guid, DateTime.UtcNow.AddDays(30)); byte[] jsonBytes = Encoding.UTF8.GetBytes(result); response.Contents = _stream => _stream.Write(jsonBytes, 0, jsonBytes.Length); } else { response = result; } response.ContentType = "application/json"; return(response); }; Get["/logout"] = _parameters => { return(this.LogoutAndRedirect("/logoutcomplete")); }; Get["/logoutcomplete"] = _parameters => { return(View["logout.sshtml"]); }; Get["/reset"] = _parameters => { return(View["reset.sshtml"]); }; Post["/reset"] = _parameters => { Response response = HandleResetPassword(_parameters); response.ContentType = "application/json"; return(response); }; Get["/register"] = _parameters => { return(View["register.sshtml"]); }; Post["/register"] = _parameters => { Response response = (Response)Register(_parameters); response.ContentType = "application/json"; return(response); }; }