public void ProcessRequest(HttpContext context) { try { string loginName = context.Request["loginName"]; string email = context.Request["email"]; Account a = AccountHelper.GetAccountByLoginName(loginName); if (a == null) { context.Response.Write("用户名不存在!"); } else if (a.Email != email) { context.Response.Write("您输入的邮件地址不正确!"); } else if (AccountMails.SendMailOfValidate(a, We7.Model.Core.UI.Constants.FEID)) { context.Response.Write("0"); } } catch (Exception ex) { context.Response.Write(ex.Message); } }
/// <summary> /// 验证用户 /// </summary> void Authenticate() { IAccountHelper AccountHelper = AccountFactory.CreateInstance(); Account act = AccountHelper.GetAccountByLoginName(Name); if (act == null) { Message = "该用户不存在!"; return; } if (!AccountHelper.IsValidPassword(act, Password)) { Message = "密码不正确!"; return; } Security.SetAccountID(act.ID); }
void Signin() { string name = Request["UserName"]; string password = Request["Password"]; if (String.Compare(name, SiteConfigs.GetConfig().AdministratorName, true) == 0 && CDHelper.AdminPasswordIsValid(password)) { Security.SetAccountID(We7Helper.EmptyGUID); } else { IAccountHelper helper = AccountFactory.CreateInstance(); Account account = helper.GetAccountByLoginName(name); if (account != null && helper.IsValidPassword(account, password)) { Security.SetAccountID(account.ID); } } }
/// <summary> /// 找回用户密码 /// </summary> /// <param name="loginName">用户名</param> /// <param name="Mail">Email</param> /// <param name="AccountHelper">权限业务对象</param> /// <returns></returns> public string GetMyPassword(string loginName, string Mail, IAccountHelper AccountHelper) { if (String.Compare(loginName, SiteConfigs.GetConfig().AdministratorName, true) == 0) { if (Mail == GetSystemMail()) { Account ad = new Account(); ad.LastName = "管理员"; ad.Email = Mail; ad.LoginName = SiteConfigs.GetConfig().AdministratorName; ad.Password = SiteConfigs.GetConfig().AdministratorKey; ad.IsPasswordHashed = GetPasswordIsHashed(); return(SendPasswordByMail(ad, AccountHelper)); } else { return("对不起,您输入的邮箱不是管理员指定的系统邮件地址!"); } } else { Account act = AccountHelper.GetAccountByLoginName(loginName); if (act == null) { return("指定的用户不存在。"); } else if (act.State != 1) { return("该帐户不可用。"); } else if (act.Email != Mail) { return("对不起,您输入的邮箱不是您注册时填写的有效邮件地址!"); } else { return(SendPasswordByMail(act, AccountHelper)); } } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.Cache.SetNoStore(); context.Response.Clear(); string action = context.Request["action"]; string msg = "success"; if (!String.IsNullOrEmpty(action)) { IAccountHelper helper = AccountFactory.CreateInstance(); string key = context.Request["value"]; action = action.Trim().ToLower(); Account act = null; if (action == "user") { act = helper.GetAccountByLoginName(key); if (act != null) { context.Response.Write("当前用户已存在"); return; } } if (action == "email") { act = helper.GetAccountByEmail(key); if (act != null) { context.Response.Write("当前Email已被注册"); return; } } if (action == "validate") { act = helper.GetAccount(context.Request["AccountID"], null); if (act == null) { context.Response.Write("验证帐号不存在,请重新申请帐号!"); } else { act.EmailValidate = 1; act.State = 1; helper.UpdateAccount(act, new string[] { "EmailValidate", "State" }); } } if (action == "submit") { Account newAccout = new Account(); newAccout.LoginName = context.Request["name"]; newAccout.Password = context.Request["pwd"]; if (SiteConfigs.GetConfig().IsPasswordHashed) { newAccout.Password = Security.Encrypt(newAccout.Password); } newAccout.Email = context.Request["email"]; newAccout.UserType = 1; newAccout.Created = DateTime.Now; try { helper.AddAccount(newAccout); if (SendEmail(newAccout, context.Request)) { msg += ":email"; } } catch (Exception ex) { context.Response.Write(ex.Message); return; } } } context.Response.Write(msg); }