public async Task <ActionResult> ValidateToken(string token, string phone, string tokenDevice) { //if (!tokenOtpDA.ValidateToken(token, phone, (int)TokenOtpType.Authen)) //{ // return Json(new JsonMessage(1000, "Thông tin đăng nhập không hợp lệ"), JsonRequestBehavior.AllowGet); //} //tokenOtpDA.UpdateIsUsed(token, phone); //await tokenOtpDA.SaveAsync(); var customer = _agencyDa.GetByPhone(phone); var key = Guid.NewGuid(); IAuthContainerModel model = new JWTContainerModel() { Claims = new Claim[] { new Claim("Phone", customer.Phone), new Claim("Type", "Token"), new Claim("ID", customer.ID.ToString()), }, ExpireMinutes = 10, }; IAuthContainerModel modelRefreshToken = new JWTContainerModel() { Claims = new Claim[] { new Claim("Phone", customer.Phone), new Claim("Type", "RefreshToken"), new Claim("key", key.ToString()), new Claim("ID", customer.ID.ToString()), }, ExpireMinutes = 60 * 24 * 30, }; var tokenResponse = JWTService.Instance.GenerateToken(model); var refreshToken = JWTService.Instance.GenerateToken(modelRefreshToken); _agencyDa.InsertToken(new TokenRefresh() { GuidId = key }); customer.TokenDevice = tokenDevice; _agencyDa.Save(); return(Json(new BaseResponse <CustomerAppIG4Item>() { Code = 200, Erros = false, Message = "", Data = new CustomerAppIG4Item() { Token = tokenResponse, RefreshToken = refreshToken, ID = customer.ID, IsPrestige = customer.IsFdi, IsVerify = customer.IsVerify, IsBank = customer.IsBank, IsActive = customer.IsActive } }, JsonRequestBehavior.AllowGet)); }