Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. string PasswordSalt = Crypto.HashPassword(DateTime.Now.ToString());
  2. string hashPassword = Crypto.HashPassword(formcollection["PassWord"]); //Hash User PassWord
  3. user.PassWord = Crypto.HashPassword(PasswordSalt + hashPassword);//Add Salt to Password For Futher Security
  4. user.PassWordSalt = PasswordSalt;
  5.  
  6. Users ThisUser = Users.UsersGetByEmail((string)Session["email"]);
  7. string checkpassword = ThisUser.PassWord;
  8.  
  9. //User Inputed password.
  10. string password = user.PassWord;
  11.  
  12.  
  13.  
  14.  
  15. if (password != null)
  16. {
  17. //Need to fix.
  18. string encrypt_password = Crypto.HashPassword(password);
  19. string salted_password = Crypto.HashPassword(ThisUser.PassWordSalt + encrypt_password);
  20. //bool does_password_match = Crypto.VerifyHashedPassword(checkpassword, password);
  21. if (checkpassword == salted_password)
  22. {
  23. //Check if the inputed password matches the password from the Database.
  24.  
  25. //Remember to give session based on the user_id.
  26. Session["user_id"] = ThisUser.Id;
  27. return RedirectToAction("Promise");
  28.  
  29.  
  30. }
  31. else
  32. {
  33.  
  34. ModelState.AddModelError("PassWord", "Wrong Password, Please Enter Correct Password");
  35. return View(user);
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement