本文介绍了密码没有更新......?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 (存储过程(ManageMember)) 如果 @Check = ' u' 开始 update 会员 设置密码= @ Password ,Name = @ Name ,Email = @ Email ,Phone = @ Phone , Company = @ Company ,性别= @ Gender ,BirthDate = @ BirthDate ,问题= @Question ,答案= @答案 其中(UserName = @用户名) end ---------------- -------------------------------------------------- ---------- (MainTable.cs) public bool 更新() { return LoadPropertiesToList( u); } ------------------------------ ---------------------------------------------- (Member.cs) 受保护 覆盖 bool LoadPropertiesToList( string TypeOfOperation) { SortedList SL = new SortedList(); SL.Add( @ Check,TypeOfOperation); SL.Add( @ Username,用户名); SL.Add( @ Password,密码); SL.Add( @ Name,Name); SL.Add( @ Email,电子邮件); SL.Add( @ Phone,Phone); SL.Add( @ Company,Company); SL.Add( @ Gender,性别); SL.Add( @ BirthDate,BirthDate); SL.Add( @ Question,问题); SL.Add( @ Answer,答案); ProcedureName = ManageMember; if (db.RunProcedure(ProcedureName,SL)== 1 ) return true ; else return false ; } ------------------------------ ------------------------------------------------ (Utility.cs) public static string ReadFromCookie( string CookieName, string Key,HttpRequest req) { try { return req.Cookies [CookieName] [Key] .ToString(); } catch { return 空; } } ------------------------- -------------------------------------------------- (wucLogin.ascx.cs) protected void Page_Load( object sender,EventArgs e) { string User = Utility.ReadFromCookie( Login, 用户名,请求); if (User!= null ) {重定向(用户); } } ------------------------- -------------------------------------------------- ------- (wucChangePassword.ascx.cs) {会员M = new Member(); static string 用户; 受保护 void Page_Load( object sender,EventArgs e) { User = Utility.ReadFromCookie( 登录, 用户名,请求); lblUser.Text =用户; } 受保护 void btnChange_Click( object sender,EventArgs e) { User = Utility.ReadFromCookie( 登录, 用户名,请求); if (txtNewPass.Text!= txtRePass.Text) lblMsgPass.Text = 密码和确认密码不一样; else { if (M.ChangePassword(User, txtNewPass.Text)) lblMsgPass.Text = 密码已成功更改; else lblMsgPass.Text = 出错; } } } 我尝试了什么: public bool ChangePassword( string 用户名,字符串 NewPassword) {? ??????????????????????????????? } 解决方案 停止尝试使其工作,并整理您的密码系统:绝不以明文形式存储密码 - 这是一个重大的安全风险。有关如何在此处执行此操作的信息:密码存储:如何做到这一点。 [ ^ ] 以明文形式存储密码是 codecrime [ ^ ]所以你所做的所有工作都被浪费了...... (Stored Procedure (ManageMember))if @Check ='u' beginupdate Memberset Password = @Password, Name = @Name, Email = @Email, Phone = @Phone, Company = @Company, Gender = @Gender, BirthDate = @BirthDate, Question = @Question, Answer = @Answerwhere (UserName = @Username)end----------------------------------------------------------------------------(MainTable.cs) public bool Update() { return LoadPropertiesToList("u"); }----------------------------------------------------------------------------(Member.cs)protected override bool LoadPropertiesToList(string TypeOfOperation) { SortedList SL = new SortedList(); SL.Add("@Check", TypeOfOperation); SL.Add("@Username", Username); SL.Add("@Password", Password); SL.Add("@Name", Name); SL.Add("@Email", Email); SL.Add("@Phone", Phone); SL.Add("@Company", Company); SL.Add("@Gender", Gender); SL.Add("@BirthDate", BirthDate); SL.Add("@Question", Question); SL.Add("@Answer", Answer); ProcedureName = "ManageMember"; if (db.RunProcedure(ProcedureName, SL) == 1) return true; else return false; }------------------------------------------------------------------------------(Utility.cs)public static string ReadFromCookie(string CookieName,string Key,HttpRequest req){ try { return req.Cookies[CookieName][Key].ToString(); } catch { return null; }}---------------------------------------------------------------------------(wucLogin.ascx.cs)protected void Page_Load(object sender, EventArgs e){string User = Utility.ReadFromCookie("Login","Username", Request);if (User != null){Redirect(User);}}----------------------------------------------------------------------------------(wucChangePassword.ascx.cs){Member M = new Member();static string User;protected void Page_Load(object sender, EventArgs e){User = Utility.ReadFromCookie("Login", "Username", Request);lblUser.Text = User;}protected void btnChange_Click(object sender, EventArgs e){User = Utility.ReadFromCookie("Login", "Username", Request);if (txtNewPass.Text != txtRePass.Text)lblMsgPass.Text = "The Password and Confirm Password is not the same";else{if (M.ChangePassword(User, txtNewPass.Text))lblMsgPass.Text = "Password Changed Successfuly";elselblMsgPass.Text = "Something Error";}}}What I have tried:public bool ChangePassword(string Username, string NewPassword) { ???????????????????????????????? } 解决方案 Stop trying to get that working, and sort out your passwords system: Never store passwords in clear text - it is a major security risk. There is some information on how to do it here: Password Storage: How to do it.[^]Storing passwords in clear text is a codecrime[^] so all of the work you have put into this is pretty much wasted... 这篇关于密码没有更新......?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-19 12:04