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); }
private void SaveUserHistory() { if (cRememberPwd.Checked) { LocalUserProfile.SaveContent(_vm.UserName, "password", _vm.Password); } else { LocalUserProfile.Delete(_vm.UserName, "password"); } }