public override bool Submit() { if (!base.Submit()) { return(false); } using (SnokyeContainer container = new SnokyeContainer()) { string hashValue = Password.GetMD5(); #if DEBUG if (!container.UserInfoSet.Any()) { UserInfo __admin = new UserInfo { DisplayName = "系统管理员", Password = "******".GetMD5(), UserName = "******", UserGuid = Guid.NewGuid() }; container.AddToUserInfoSet(__admin); for (int i = 0; i < 100; i++) { //0xB0A1 - 0xF7FE UserInfo u = new UserInfo { UserName = "******" + i, DisplayName = "User" + i, Password = "******".GetMD5() }; container.AddToUserInfoSet(u); container.SaveChanges(); } } #endif var user = container.UserInfoSet.FirstOrDefault(u => u.UserName == UserName && u.Password == hashValue); if (user == null) { ValidateFailed?.Invoke(nameof(UserName), "用户名不存在或密码错误!"); return(false); } if (user.Disabled) { ValidateFailed?.Invoke(nameof(UserName), "该用户已被禁用!"); return(false); } ClientInfo.CurrentUser = user; ClientInfo.UserProfile = new ServerUserProfile(user.UserGuid); } if (RememberPwd) { LocalUserProfile.SaveContent(UserName, "password", Password); } else { LocalUserProfile.Delete(UserName, "password"); } return(true); }
public override bool Submit() { if (!base.Submit()) { return(false); } using (SettlementContainer container = new SettlementContainer()) { string hashValue = Password.GetMD5(); var user = container.UserInfoSet.FirstOrDefault(u => u.UserName == UserName && u.Password == hashValue); if (user == null) { ValidateFailed?.Invoke(nameof(UserName), "用户名不存在或密码错误!"); return(false); } if (user.Disabled) { ValidateFailed?.Invoke(nameof(UserName), "该用户已被禁用!"); return(false); } ClientInfo.UserID = user.Id; ClientInfo.UserLoginName = user.UserName; ClientInfo.UserName = user.DisplayName; } if (RememberPwd) { LocalUserProfile.SaveContent(UserName, "password", Password); } else { LocalUserProfile.Delete(UserName, "password"); } return(true); }
public override bool BeforeSubmit() { if (!base.BeforeSubmit()) { return(false); } if (NewPasswrod != RepPassword) { ValidateFailed?.Invoke(nameof(RepPassword), "两次输入的密码不一致!"); return(false); } using (SnokyeContainer c = new SnokyeContainer()) { var query = from u in c.UserInfoSet where u.Id == ClientInfo.CurrentUser.Id select u.Password; if (OldPassword.GetMD5() != query.FirstOrDefault()) { ValidateFailed?.Invoke(nameof(OldPassword), "原密码不正确!"); return(false); } } return(true); }