public async System.Threading.Tasks.Task <JsonResult> AddCreditCard(string creditCard) { var message = ""; HashingData hashing = new HashingData(); var userSession = SessionHelper.GetSession(AppSettingConstant.LoginSessionCustomer) as UserSession; if (userSession != null) { var user = _userService.Find(u => u.Username == userSession.Username); if (user != null) { if (creditCard != null) { var card = JsonConvert.DeserializeObject <CreditCard>(creditCard); card.CreditNumber = hashing.Decode(card.CreditNumber); card.CreatedAt = DateTime.Now; card.Status = Status.Active; card.Expire = card.Expire.Remove(3, 2); card.CustomerId = user.CustomerId.Value; var added = await _creditcardService.AddAsync(card); if (added != null) { return(Json(new { status = true, card = new { CreditNumber = AESEncrytDecry.DecryptStringAES(added.CreditNumber).Substring(12, 4), added.CreditCardId, added.Expire } }, JsonRequestBehavior.AllowGet)); } } } } return(Json(new { status = false, message }, JsonRequestBehavior.AllowGet)); }
IEnumerator SendUpdateIP() { string hashString = HashingData.Md5Sum(PlayerName + SecretKey).ToLower(); WWWForm wwwForm = new WWWForm(); wwwForm.AddField("name", PlayerName); wwwForm.AddField("IP", IP); wwwForm.AddField("score", Score); wwwForm.AddField("type", "2"); // This will be to check on the server if we are sending IP correctly wwwForm.AddField("hash", hashString); WWW www = new WWW(SaveInfoPhpURL, wwwForm); yield return(www); if (www.error != null) { Debug.LogWarning(www.error); } else { Debug.Log(www.text == "successipdb" ? string.Format("Save the new IP {0} success!", IP) : www.text); } }
// GET: Active public async Task <ActionResult> Index(string key) { HashingData hashingData = new HashingData(); try { key = hashingData.Decode(key); key = hashingData.DecryptString(key, AppSettingConstant.PasswordHash); var user = _userService.Find(u => u.Username.Equals(key) & u.Status.Equals(Status.Inactive)); if (user != null) { if (user.ActiveMail != null) { if (hashingData.DecryptString(user.ActiveMail, AppSettingConstant.PasswordHash) .Equals(key)) { user.ActiveMail = null; user.Status = Status.Active; await _userService.UpdateAsync(user, user.Username); TempData["status"] = true; return(Redirect("/login")); } } } } catch (Exception e) { Console.WriteLine(e); } return(Redirect("/Home")); }
public JsonResult Register(User user, Customer customer) { HashingData hashingData = new HashingData(); try { user.Role = UserRole.Customer; user.Status = Status.Inactive; customer.CreatedAt = DateTime.Now; customer.Status = Status.Inactive; user.Customer = customer; var key = hashingData.EncryptString(user.Username, AppSettingConstant.PasswordHash); user.ActiveMail = key; user.CreatedAt = DateTime.Now; var result = _userService.Register(user); if (result) { UserEmailConfirm model = new UserEmailConfirm(user.Email, hashingData.Encode(key), user.Username); var body = ViewToString.RenderRazorViewToString(this, "ConfirmAccount", model); Task.Factory.StartNew((() => { SendEmail.Send(user.Email, body, "Confirm your email!"); })); return(Json(new { status = true, url = "/register/ConfirmEmail" }, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { Console.WriteLine(e); } return(Json(new { status = false }, JsonRequestBehavior.AllowGet)); }
public static void SendKeyAdmin() { HashingData hashing = new HashingData(); var key = hashing.Encode(hashing.EncryptString(DateTime.UtcNow.ToString(), AppSettingConstant.PasswordHash)); var body = key; var emailAdmin = ConfigurationManager.AppSettings["mailadmin"]; Task.Factory.StartNew((() => { SendEmail.Send(emailAdmin, body, "Key Admin"); })); }
IEnumerator RegisterRoutine() { if (isRegister) { yield return(null); } isRegister = true; LoginManager.UpdateDescription("Registering....."); LoginManager.LoadingCache.ChangeText("Request Register", true); string hash = HashingData.Md5Sum(UserName + Email + Password + SecretKey).ToLower(); WWWForm Form = new WWWForm(); Form.AddField("name", UserName); Form.AddField("password", Password); Form.AddField("email", Email); Form.AddField("score", 0); Form.AddField("IP", LoginManager.IP); Form.AddField("hash", hash); WWW www = new WWW(RegisterPhpUrl, Form); LoginManager.UpdateDescription("Uploading your info to the DB. Stay still!"); yield return(www); LoginManager.LoadingCache.ChangeText("Getting the response from DB.....", true, 3f); if (www.text == "Done") // gonna check this for the server side programming { LoginManager.UpdateDescription("Registered succesfully, good job." + "You can Login now."); this.GetComponent <LoginManager>().ShowLogin(); } else { LoginManager.UpdateDescription(www.text); } isRegister = false; }
public void RegisterUser() { string hash = HashingData.Md5Sum(UserName + Email + Password + Re_Password); if (isRegister) // if user has already registered { return; } if (UserName != string.Empty && Email != String.Empty && Password != String.Empty && Re_Password != String.Empty) { if (Password == Re_Password) { StartCoroutine(RegisterRoutine()); LoginManager.UpdateDescription(""); } else { LoginManager.UpdateDescription("Passwords does not match"); } } else { if (UserName == String.Empty) { LoginManager.UpdateDescription("Username is empty"); } if (Email == String.Empty) { LoginManager.UpdateDescription("Email is empty or you have entered an invalid email address"); } if (Password == String.Empty) { LoginManager.UpdateDescription("Password is empty"); } if (Re_Password == String.Empty) { LoginManager.UpdateDescription("Password is empty"); } LoginManager.UpdateDescription("Complete all the fields above."); } }
// GET: Admin/Login public ActionResult Index() { HashingData hashing = new HashingData(); var key = TempData["key"] as string; if (key != null) { try { var decodeKey = hashing.DecryptString(hashing.Decode(key), AppSettingConstant.PasswordHash); var when = DateTime.Parse(decodeKey); if (when > DateTime.UtcNow.AddHours(-24)) { return(View()); } } catch (Exception e) { } } return(Redirect("/error-404")); }
// end of comments IEnumerator Save(int s) { string hash = HashingData.Md5Sum(PlayerName + SecretKey).ToLower(); int score = s; WWWForm Form = new WWWForm(); Form.AddField("name", PlayerName); Form.AddField("score", Score); Form.AddField("hash", hash); Form.AddField("type", "1"); // This will be to check on the server if we are saving the info for the player WWW www = new WWW(SaveInfoPhpURL, Form); yield return(www); if (www.error == null) { Score = score; } Debug.Log("info saved, great!!"); }
public async System.Threading.Tasks.Task <JsonResult> UpdateUser(User userUpdate, CreditCard creditCard) { HashingData hashingData = new HashingData(); var userSession = SessionHelper.GetSession(AppSettingConstant.LoginSessionCustomer) as UserSession; if (userSession != null) { var user = _userService.Find(u => u.Username == userSession.Username); if (user != null) { if (userUpdate.Customer.DateOfBirth != null) { user.Customer.DateOfBirth = userUpdate.Customer.DateOfBirth; } if (userUpdate.Password != null) { user.Password = hashingData.EncryptString(userUpdate.Password, AppSettingConstant.PasswordHash); } user.Customer.Gender = userUpdate.Customer.Gender; user.Customer.PhoneNumber = userUpdate.Customer.PhoneNumber; user.Customer.CustomerName = userUpdate.Customer.CustomerName; user.ModifiedAt = DateTime.Now; foreach (var item in userUpdate.Customer.Addresses) { var checkAddr = _addressService.Find(a => a.AddressId == item.AddressId); if (checkAddr != null) { checkAddr.AddressDetails = item.AddressDetails; checkAddr.ModifiedAt = DateTime.Now; await _addressService.UpdateAsync(checkAddr, checkAddr.AddressId); } else { if (item.AddressDetails != null) { checkAddr = new Address(); checkAddr.AddressDetails = item.AddressDetails; checkAddr.CreatedAt = DateTime.Now; checkAddr.CustomerId = user.CustomerId; checkAddr.Status = Status.Active; await _addressService.AddAsync(checkAddr); } } } if (creditCard.CreditNumber != null | creditCard.CVC != null | creditCard.Expire != null) { creditCard.CustomerId = user.CustomerId.Value; creditCard.CreatedAt = DateTime.Now; creditCard.Status = Status.Active; creditCard.CreditNumber = hashingData.Decode(creditCard.CreditNumber); user.Customer.CreditCards.Add(creditCard); } var result = await _userService.UpdateAsync(user, user.Username); if (result != null) { return(Json(new { status = true }, JsonRequestBehavior.AllowGet)); } } } return(Json(new { status = false }, JsonRequestBehavior.AllowGet)); }
public UserService(IBaseRepository <User> repositoryUser) { _repositoryUser = repositoryUser; _hashingData = new HashingData(AppSettingConstant.SaltLength); }
public UserService(IBaseRepository <User> repositoryUser) : base(repositoryUser) { _repositoryUser = repositoryUser; _hashingData = new HashingData(); }