public IActionResult Authenticate([FromBody] AuthenticationContract auth) { var token = this.authenticationService.SignIn(auth.Login, auth.Password); return(Ok(new { Token = token })); }
public IActionResult Login([FromBody] AuthenticationContract auth) { var user = this.service.GetByEmailAndPassword(auth.Email, auth.Password); if (user == null) { return(BadRequest(new Exception("User or password invalid."))); } return(StatusCode(200, new { Token = this.CreateToken(user) })); }
//Service Trade Authorization private void GetAuthorization() { var client = new RestClient(); client.EndPoint = @uriStr + "auth"; client.Method = HttpVerb.POST; client.ContentType = "application/json"; client.PostData = credentials; //Get Authorization Log st.insertLog(client.EndPoint + client.Method + client.PostData.ToString(), "Service Trade Authorization", "NA", HillerServiceDataMigrator.LogId); using (var response = client.MakeRequest()) { DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(AuthenticationContract)); object objResponse = jsonSerializer.ReadObject(response.GetResponseStream()); AuthenticationContract jsonResponse = objResponse as AuthenticationContract; authorization = jsonResponse.Authentication; response.Close(); } }