public async Task <IActionResult> Login([FromBody] LoginModel loginModel) { try { if (loginModel == null) { return(BadRequest("Invalid client request")); } var authorization = await authorizeRepository.GetByUserName(loginModel.UserName); if (authorization == null) { return(BadRequest("That username does not exist")); } if (hashingService.CheckHash(authorization.Password, loginModel.Password)) { var tokenString = tokenService.CreateToken(authorization); return(Ok(new { Token = tokenString, UserId = authorization.CustomerId })); } else { return(Unauthorized()); } } catch (Exception ex) { return(StatusCode(500, $"Internal server error: {ex.Message}")); } }