public static string OnApplyMemberKey(string user, string vcode) { int code = 0; string message; if ( String.Compare(Convert.ToString(HttpContext.Current.Session["VerifyCode"]), vcode, StringComparison.OrdinalIgnoreCase) != 0) { message = "验证码不正确"; code = 0; return(JsonConvert.SerializeObject(new { Code = code, Message = message })); } var serviceClient = new SmartHsServiceClient(); var result = serviceClient.FindMemberByName(user); var jobj = JObject.Parse(result); if (Convert.ToInt32(jobj["Code"]) != 1) { message = "未找到该注册用户"; code = 0; return(JsonConvert.SerializeObject(new { Code = code, Message = message })); } //发送邮件 var mail = jobj["Message"]["mail"].Value <string>(); var confirm = Guid.NewGuid().ToString(); DateTime now = DateTime.Now; var sessionResult = serviceClient.AddSessionVerify(now.Ticks, user, confirm); jobj = JObject.Parse(sessionResult); if (Convert.ToInt32(jobj["Code"]) != 1) { message = "服务器生成验证url失败"; code = 0; return(JsonConvert.SerializeObject(new { Code = code, Message = message })); } //var testmail = "*****@*****.**"; //bool success = SendModifyPwdEmail(user, testmail, now, confirm); bool success = SendModifyPwdEmail(user, mail, now, confirm); return(JsonConvert.SerializeObject(new { Code = success?1:0, string.Empty })); }
public static string ResetMemberKey(string user, string pwd1, string pwd2, string orignal, long session) { if (String.CompareOrdinal(pwd1, pwd2) != 0) { return(JsonConvert.SerializeObject(new { Code = 0, Message = "两次输入密码不一致!" })); } var serviceClient = new SmartHsServiceClient(); var member = serviceClient.FindMemberByName(user); var jObj = JObject.Parse(member); if (Convert.ToInt32(jObj["Code"]) != 1) { return(JsonConvert.SerializeObject(new { Code = 0, Message = "该注册用户不存在!" })); } if (string.IsNullOrWhiteSpace(orignal) && session <= 0) { return(JsonConvert.SerializeObject(new { Code = 0, Message = "此次请求不合法或已失效!" })); } if (session > 0) { var can = serviceClient.CanUseSessionById(session); var canObj = can.JObjParse(); if (Convert.ToInt32(canObj["Code"]) != 1) { return(JsonConvert.SerializeObject(new { Code = 0, Message = "此次请求链接已使用或过期!" })); } string json = JsonConvert.SerializeObject(new { member_key = pwd1 }); var result = serviceClient.UpdateMember(Convert.ToInt64(jObj["Message"]["member_id"]), json); serviceClient.ReadyToUseSessionVerify(session); return(result); } else { var update = serviceClient.UpdateMemberKey(user, orignal, pwd1); return(update); } return(""); }