public ActionResult GetJWT([FromQuery] Parameters parameters)
        {
            try
            {
                if (parameters == null)
                {
                    return(Json(new ResponseData
                    {
                        Code = "901",
                        Message = "null of parameters",
                        Data = null
                    }));
                }

                if (parameters.grant_type == "password")
                {
                    return(Ok(Json(TH.DoPassword(parameters, _repo, _settings, users_collection))));
                }
                else if (parameters.grant_type == "refresh_token")
                {
                    return(Ok(Json(TH.DoRefreshToken(parameters, _repo, _settings, users_collection))));
                }
                else
                {
                    return(Json(new ResponseData
                    {
                        Code = "904",
                        Message = "bad request",
                        Data = null
                    }));
                }
            }
            catch (Exception ex)
            {
                SL.CreateLog("TokenController", "GetJWT", ex.Message);
                return(BadRequest(new ResponseData
                {
                    Code = "400",
                    Message = "Failed",
                    Data = null
                }));
            }
        }
 public ActionResult Login([FromBody] LoginModel data)
 {
     try
     {
         var check = MH.CheckForData(users_collection, "UserName", data.UserName, null, null).Result;
         if (check == true)
         {
             var getUser = BsonSerializer.Deserialize <RegisterModel>(MH.GetSingleObject(users_collection, "UserName", data.UserName, null, null).Result);
             if (getUser.UserVerified == true && getUser.IsActive == true)
             {
                 RegisterModel registerModel = new RegisterModel {
                     UserName = data.UserName, FullName = getUser.FullName, Password = data.Password
                 };
                 if (passwordHasher.VerifyHashedPassword(registerModel, getUser.Password, data.Password).ToString() == "Success")
                 {
                     Parameters parameters = new Parameters {
                         username = getUser.UserName, fullname = getUser.FullName
                     };
                     var result = TH.DoPassword(parameters, _repo, _settings, users_collection);
                     return(Ok(Json(result)));
                 }
                 else
                 {
                     return(BadRequest(new ResponseData
                     {
                         Code = "402",
                         Message = "Incorrect password"
                     }));
                 }
             }
             else
             {
                 if (getUser.UserVerified == false)
                 {
                     return(BadRequest(new ResponseData
                     {
                         Code = "401",
                         Message = "User not verified"
                     }));
                 }
                 else
                 {
                     return(BadRequest(new ResponseData
                     {
                         Code = "402",
                         Message = "User not active"
                     }));
                 }
             }
         }
         else
         {
             return(BadRequest(new ResponseData
             {
                 Code = "404",
                 Message = "User not found"
             }));
         }
     }
     catch (Exception ex)
     {
         SL.CreateLog("AuthController", "Login", ex.Message);
         return(BadRequest(new ResponseData
         {
             Code = "400",
             Message = "Failed",
             Data = ex.Message
         }));
     }
 }