Exemple #1
0
        public async Task <HttpResponseMessage> AuthenticateCustomer(DtoSignIn signInData)
        {
            var authResult = await AuthenticationLogic.AuthenticateCustomer(signInData);

            var token = AuthenticationLogic.GetToken(signInData.EMail);
            var resp  = new SignInResponse {
                AuthorizationResult = authResult, Token = token
            };
            var response = Request.CreateResponse(HttpStatusCode.OK, resp);

            return(response);
        }
 public IActionResult Get(string departmentCode, string username, string password)
 {
     if (!QueryParameters.IsValid(departmentCode, 20) || !QueryParameters.IsValid(username, 50) || string.IsNullOrEmpty(password))
     {
         return(BadRequest());
     }
     try
     {
         var tokenResult = AuthenticationLogic.GetToken(username, password, departmentCode);
         var token       = tokenResult.Token;
         return(Ok(token));
     }
     catch (AuthenticationException)
     {
         return(Unauthorized());
     }
     catch (Exception ex)
     {
         return(StatusCode(500));
     }
 }