public async System.Threading.Tasks.Task <JsonResult> SendWithdrawETH(int type, string username, string password, string toAddress, string amount, int speed, string fee) { try { var timeStamp = CommonCalculate.GetTimeStamp(); var killFundist = _sdkApiFundist.ApiKill_Authorization(username, timeStamp); var _user = _userManager.FindByName(username); var obj = new { type = type, username = username, password = password, toaddress = toAddress, amount = amount, speed = speed, timestamp = timeStamp }; var CalcApiTransaction = await _sdkApiAdmin.SDKApiTransactionPostAsync(DOMAIN_API_ADMIN + "api/transaction/", obj);//gọi đến api type = 3 đê var res = JsonConvert.DeserializeObject <MessageResponeApiAdmin>(CalcApiTransaction.ToString()); string[] arrStr = res.Message.Split('_');//arrstr[2]: balance giao dịch, arrstr[1]:id transaction, arrstr[3]: phí transaction, arrstr[4]: ngày tạo if (res.Code == 1) { var sendMailRes = await _sdkApiAdmin.SDKApiSendMailWidthdrawETHAsync(_user.Id, _user.Email, arrStr[2], toAddress, arrStr[3], _user.UserName, timeStamp, arrStr[1], 2); } log.Info("Success withdraw"); return(Json(arrStr[0], JsonRequestBehavior.AllowGet)); } catch (Exception ex) { log.Info("Error exception withdraw" + ex); return(Json(null, JsonRequestBehavior.AllowGet)); } }
public async System.Threading.Tasks.Task <JsonResult> SendWidthdrawVIP(int type, string usernameFrom, string password, string UsernameToAddress, string amount, string fee, string email, string id) { try { var timeStamp = CommonCalculate.GetTimeStamp(); var killFundist = _sdkApiFundist.ApiKill_Authorization(usernameFrom, timeStamp); var obj = new { type = type, username = usernameFrom, password = password, toaddress = UsernameToAddress, amount = amount, timestamp = timeStamp, speed = 0 };//type 5 //var _user = _userManager.FindByName(UsernameToAddress);//kiểm tra db web có tồn tại username này không //if(_user == null) //{ // return Json(new { Message = "User name from invalided. Please check again", status = "Failed" }); //} var CalcApiTransaction = await _sdkApiAdmin.SDKApiTransactionPostAsync(DOMAIN_API_ADMIN + "api/transaction/", obj); var res = JsonConvert.DeserializeObject <MessageResponeApiAdmin>(CalcApiTransaction); string[] arrStr = res.Message.Split('_'); if (res.Code == 1) { var mailRes = await _sdkApiAdmin.SDKApiSendMailWidthdrawVIPAsync(id, email, arrStr[2], UsernameToAddress, arrStr[3], usernameFrom, timeStamp, arrStr[1], 3); } log.Info("Success exchange" + CalcApiTransaction); return(Json(arrStr[0], JsonRequestBehavior.AllowGet)); } catch (Exception ex) { log.Info("Error exception SendExchange" + ex); return(Json(null, JsonRequestBehavior.AllowGet)); } }
public ActionResult CheckMailTimeout(string tokenId, string timestamp) { var resultDuration = CommonCalculate.ConvertUTC7() - ConvertTimestampToDate.ConvertCustomDate(timestamp); //lấy ngày hiện tại qua hàm ConverUTC7 if (resultDuration.TotalMinutes <= 30) //kiểm tra thời gian timeout của mail { return(RedirectToAction("FormInputForgotPassword", "EmailFunc", new { tokenId = tokenId })); } return(View(model: "Password verification time out !")); }
public async System.Threading.Tasks.Task <JsonResult> SendExchange(int type, string username, string password, string amount) { try { var timeStamp = CommonCalculate.GetTimeStamp(); var killFundist = _sdkApiFundist.ApiKill_Authorization(username, timeStamp); var obj = new { type = type, username = username, password = password, amount = amount, toaddress = "", timestamp = "", speed = 0 };//type 1 var CalcApiTransaction = await _sdkApiAdmin.SDKApiTransactionPostAsync(DOMAIN_API_ADMIN + "api/transaction/", obj); var converRes = JsonConvert.DeserializeObject <MessageResponeApiAdmin>(CalcApiTransaction); log.Info("Success exchange" + CalcApiTransaction); return(Json(converRes, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { log.Info("Error exception SendExchange" + ex); return(Json(null, JsonRequestBehavior.AllowGet)); } }
public async Task <ActionResult> ForgotPassword(InputEmailViewModel model) { if (ModelState.IsValid) { try { var user = await _userManager.FindByEmailAsync(model.EmailReset); if (user == null || !(user.EmailConfirmed)) { // Don't reveal that the user does not exist or is not confirmed return(View(model: "Email is not registered. Please check again!!!")); } //var code = await _userManager.GeneratePasswordResetTokenAsync(user.Id); //gọi đến function email gửi mail xác thực lấy lại mật khẩu log.Info(DateTime.Now + "_Start call api mail"); var resForgot = await _confirmEmail.CallMailResetPass(CommonCalculate.GetTimeStamp().ToString(), user.UserName, 5);//5 là type để lưu log.Info(DateTime.Now + "_End call api mail"); MessageResponeApi mess = JsonConvert.DeserializeObject <MessageResponeApi>(resForgot); if (mess.StatusCode.Equals("1")) { return(View(model: "A verification code is sent to your mail. Please check mail to reset your password (**Note: Effective 30 minutes)")); } return(View(model: "A verification code isn't sent to your mail")); } catch (Exception ex) { log.Info("Error exception function forgot password_" + DateTime.Now + ": " + ex); return(View(model: "Reset mail failed. Please try again !!!")); } } return(View(model: "Reset mail failed. Please try again !!!")); // If we got this far, something failed, redisplay form }
public async Task <ActionResult> Register(RegisterViewModel model) { CaptchaResponse response = _captcha.ValidateCaptcha(Request["g-recaptcha-response"]); try { if (ModelState.IsValid) { //kiểm tra user name khi được nhập vào var checkUser = _userManager.FindByName(model.UserName.ToLower()); //check mail var checkEmailAddress = _userManager.FindByEmail(model.Email); if (checkEmailAddress != null)// mail tồn tại không cho tạo tk { ModelState.AddModelError("", "Email existed"); //return RedirectToAction("Register", "Account"); } else { //kiểm tra username có tồn tại trong db hay chưa, null là username chưa có -> có thể đăng ký được if (checkUser == null) { //kiểm tra parent id if (!string.IsNullOrEmpty(model.Affilate_ID)) { var checkParentId = _userManager.FindByName(model.Affilate_ID); //chính là user name if (checkParentId != null && checkParentId.EmailConfirmed == true) // tồn tại affilliate cho tạo tk + trùng mail thì không cho tạo tk { //var checkParentId = _userManager.FindById(findUserParent.Id); //Neu parent exist thi them parent vao User userParent = new User() { UserName = model.UserName.ToLower().Replace(" ", string.Empty), Email = model.Email, ParentId = checkParentId.Id, PasswordNotHash = model.Password, Temp2 = model.Password, // để lưu khi đổi pass Activated = true //tạo mặc định để có thể lock hoặc unclock trong admin }; var ip = IPClient.getIP(); //chỉ dùng cho web golive if (ip.Equals("::1")) { log.Info("Ip localhost: " + ip + "_" + DateTime.Now); ip = SERVER_IP; } var CallApiFundist = await _sdkApiFundits.ApiCreateUser(model.UserName.ToLower().Replace(" ", string.Empty), model.Password, CommonCalculate.GetTimeStamp(), ip, model.UserName);//tạo account fundist if (CallApiFundist.Equals("1")) { var qrImage = _twoFact.GetQrCodeImage(model.UserName.ToLower().Replace(" ", string.Empty)); var qrText = _twoFact.GetQrCodeText(model.UserName.ToLower().Replace(" ", string.Empty)); userParent.Temp = qrImage; userParent.Temp1 = qrText; var resultParent = await _userManager.CreateAsync(userParent, model.Password); //tạo account trong db web var userId = _userManager.FindByName(model.UserName.ToLower().Replace(" ", string.Empty)); //tìm username trong db web để lấy ra id của user log.Info("Start mail register"); var resultSendMail = await _confirmEmail.CallMailRegister(CommonCalculate.GetTimeStamp(), model.UserName.ToLower().Replace(" ", string.Empty), 4); //gửi mail xác nhận đăng ký //gọi api admin để tạo ví var jsonObject = new { username = userId.UserName, password = userId.PasswordNotHash, usernameParent = model.Affilate_ID }; var CallApiAdmin = await _sdkApiAdmin.SDKApiAdminPostAsync(DOMAIN_API + "api/Account/", jsonObject);//gọi api tạo account admin JObject ApiAdminCall = JObject.Parse(CallApiAdmin); //tim username upate address, balance ETH, balance VIP var a = ApiAdminCall["UserName"].ToString(); var findUseName = _userManager.FindByName(a); if (findUseName != null) { findUseName.Address_Crypto = ApiAdminCall["AdressKey"].ToString(); findUseName.Balance_ETH = ApiAdminCall["Balance"].ToString(); findUseName.Balance_VIP = ApiAdminCall["BalanceVip"].ToString(); _userManager.Update(findUseName); } ///// if (resultParent.Succeeded) { // await SignInAsync(userParent, isPersistent: false);//tắt auto đăng nhập khi đăng ký thành công return(RedirectToAction("sendMailConfirm", "EmailFunc", new { message = resultSendMail })); } else { ModelState.AddModelError("", "Invalid: " + resultParent); } } else { log.Info("Error when call api fundist: " + CallApiFundist); ModelState.AddModelError("Invalid: ", CallApiFundist); } } else { log.Info("Error invalid Affilate"); //Thông báo lỗi parent ModelState.AddModelError("Parent invalid or email existed", "Affiliate ID does not exis !"); } } else { User userParent = new User() { UserName = model.UserName.ToLower().Replace(" ", string.Empty), Email = model.Email, PasswordNotHash = model.Password, ParentId = PARENT_ID, Temp2 = model.Password, // để lưu khi đổi pass Activated = true //tạo mặc định để có thể lock hoặc unclock trong admin }; var ip = IPClient.getIP(); //chỉ dùng cho web golive if (ip.Equals("::1")) { ip = SERVER_IP; } var CallApiFundist = await _sdkApiFundits.ApiCreateUser(model.UserName.ToLower().Replace(" ", string.Empty), model.Password, CommonCalculate.GetTimeStamp(), ip, model.UserName);//gọi api fundist //chưa check if (CallApiFundist.Equals("1")) { userParent.Temp = _twoFact.GetQrCodeImage(model.UserName.ToLower().Replace(" ", string.Empty)); userParent.Temp1 = _twoFact.GetQrCodeText(model.UserName.ToLower().Replace(" ", string.Empty)); var resultParent = await _userManager.CreateAsync(userParent, model.Password); //tạo account ở db web var userId = _userManager.FindByName(model.UserName.ToLower().Replace(" ", string.Empty)); //tìm username trong db web để lấy ra id của user log.Info("Send mail"); //Gửi mail xác nhận đăng ký var resultSendMail = await _confirmEmail.CallMailRegister(CommonCalculate.GetTimeStamp(), model.UserName.ToLower().Replace(" ", string.Empty), 4); //gửi mail xác nhận đăng ký var jsonObject = new { username = userId.UserName, password = userId.PasswordNotHash, usernameParent = "avataclub" }; var CallApiAdmin = await _sdkApiAdmin.SDKApiAdminPostAsync(DOMAIN_API + "api/Account/", jsonObject);//tạo account trên admin log.Info("Account create api admin: " + CallApiAdmin); if (!string.IsNullOrEmpty(CallApiAdmin)) { JObject ApiAdminCall = JObject.Parse(CallApiAdmin); //tim username upate address, balance ETH, balance VIP var a = ApiAdminCall["UserName"].ToString(); var findUseName = _userManager.FindByName(a); if (findUseName != null) { findUseName.Address_Crypto = ApiAdminCall["AdressKey"].ToString(); findUseName.Balance_ETH = ApiAdminCall["Balance"].ToString(); findUseName.Balance_VIP = ApiAdminCall["BalanceVip"].ToString(); _userManager.Update(findUseName); } if (resultParent.Succeeded) { //await SignInAsync(userParent, isPersistent: false); return(RedirectToAction("sendMailConfirm", "EmailFunc", new { message = resultSendMail })); } else { AddErrors(resultParent); } } else { log.Info("Can't create account from api admin - End"); ModelState.AddModelError("", CallApiAdmin); } } else { log.Info("Error when call api fundist: " + CallApiFundist); ModelState.AddModelError("Invalid: ", CallApiFundist); } //var resultParent = await _userManager.CreateAsync(userParent, model.Password); //if (resultParent.Succeeded) //{ // await SignInAsync(userParent, isPersistent: false); // return RedirectToAction("Index", "Home"); //} //else //{ // AddErrors(resultParent); //} } } else { ModelState.AddModelError("", "Same name existed"); } } } // If we got this far, something failed, redisplay form return(View(model)); } catch (Exception ex) { log.Info("Error exception function register accont_" + DateTime.Now + ": " + ex); ModelState.AddModelError("", "**Error register"); return(RedirectToAction("Index", "ErrorMessage")); } }