public JsonResult UpdateLoginInfo(int id, string name, string newPwd, string currentPwd) { TblLoginInfo tblLoginInfo = new TblLoginInfo(); string currentEncrypte = tblLoginInfo.EncryptSha(tblLoginInfo.EncryptMd5(HttpUtility.UrlDecode(currentPwd))); string dbEncrypte = tblLoginInfo.GetAll().OrderBy(a => a.ID).FirstOrDefault().Password.ToString(); if (currentEncrypte == dbEncrypte) { string newPwdEncrypte = tblLoginInfo.EncryptSha(tblLoginInfo.EncryptMd5(HttpUtility.UrlDecode(newPwd))); Models.LoginInfo loginInfo = new Models.LoginInfo() { ID = id, UserName = HttpUtility.UrlDecode(name), Password = newPwdEncrypte, TransactionDate = DateTime.Now.ToString() }; tblLoginInfo.Update(loginInfo); return GetLoginInfo(); } else { return GetLoginInfo(false); } }
public string ValidateLoginIfo(string userName, string pwd, string isRemember = "false") { string returnValue; try { TblLoginInfo tblLoginInfo = new TblLoginInfo(); string currentEncryptePwd = tblLoginInfo.EncryptSha(tblLoginInfo.EncryptMd5(HttpUtility.UrlDecode(pwd))); string currentUserName = HttpUtility.UrlDecode(userName).Trim(); string dbEncryptePwd = tblLoginInfo.GetAll().OrderBy(a => a.ID).FirstOrDefault().Password.ToString(); string dbUserName = tblLoginInfo.GetAll().OrderBy(a => a.ID).FirstOrDefault().UserName.ToString(); if (!String.IsNullOrEmpty(currentEncryptePwd) && !String.IsNullOrEmpty(currentUserName) && !String.IsNullOrEmpty(dbEncryptePwd) && !String.IsNullOrEmpty(dbUserName)) { if (currentUserName == dbUserName) { if (currentEncryptePwd == dbEncryptePwd) { if (isRemember == "true") { FormsAuthentication.RedirectFromLoginPage(userName, true); } else { FormsAuthentication.RedirectFromLoginPage(userName, false); } returnValue = "true"; return returnValue; } else { returnValue = "false"; return returnValue; } } else { returnValue = "false"; return returnValue; } } else { returnValue = "false"; return returnValue; } } catch { returnValue = "false"; return returnValue; } }
protected override void Seed(PersonPageContext context) { Person defaultPerson = new Person() { Name = "Ziya", Surname = "Orhan", Photo = "/Files/Images/profile-avatar.jpg" }; context.Persons.Add(defaultPerson); // TblLoginInfo info = new TblLoginInfo(); LoginInfo defaultLoginInfo = new LoginInfo() { UserName = "******", Password = info.EncryptSha(info.EncryptMd5("1234")), TransactionDate = DateTime.Now.ToString() }; context.LoginInfos.Add(defaultLoginInfo); // context.SaveChanges(); }