/// <summary> /// 登录 /// </summary> /// <param name="account">账号</param> /// <param name="password">密码</param> /// <param name="practice">是否进行练习</param> public UserCredentials Login(string account, string password, bool practice) { IPosDeviceRepository posDeviceRepository = new PosDeviceRepository(); var deviceInfo = posDeviceRepository.Get(true); var userLogin = new LoginAction() { Account = account, Password = MD5.EncryptOutputHex(password, isUpper: false), CompanyId = deviceInfo.CompanyId, DeviceSn = deviceInfo.DeviceSn, MachineSn = deviceInfo.MachineSn, Practice = practice, StoreId = deviceInfo.StoreId }; var result = POSRestClient.Post <LoginAction, UserCredentials>("api/Session", userLogin); if (result.Successed) { loginUserInformaction = result.Data; POSRestClient.SetToken(loginUserInformaction.Token); return(loginUserInformaction); } else { throw new NetException(result.Message); } }
protected void click_BtnEntrar(object sender, EventArgs e) { if (txtUsuario.Text.Length.Equals(0) && txtPassword.Text.Length.Equals(0)) { lblMensaje.Text = "Ingrese Usuario y Contraseña"; } else { string admin = txtUsuario.Text.Trim(); LoginAction action = new LoginAction(); LoginModel model = new LoginModel(); model = action.ConsAdmin(txtUsuario.Text, txtPassword.Text); if (model.IdAdmin == 0 || model.Admin == string.Empty) { lblMensaje.Text = "Usuario o Contraseña incorrectos"; this.limpiar(); } else { Session.Add("User", model.Admin); Session.Add("IdUser", model.IdAdmin); Response.Redirect("~/Views/Administracion/ValidaCompras.aspx"); } } }
/// <summary> /// Initializes a new instance of the <see cref="LoginHandler"/> class. /// </summary> /// <param name="gameContext">The game context.</param> public LoginHandler(IGameServerContext gameContext) { this.gameContext = gameContext; this.loginAction = new LoginAction(gameContext); this.logoutAction = new LogoutAction(gameContext); this.decryptor = new Xor3Decryptor(0); }
public void ValidateSuccessLogin(User user) { var loginAction = new LoginAction(); var homePageAction = loginAction.Authentication(user); Assert.AreEqual(user.FirstName, homePageAction.GetUserName()); }
private void CheckLogin() { LoginAction la = new LoginAction(); HttpCookie Cookie = CookiesHelper.GetCookie(SiteInfo.CookieName()); if (Cookie == null) { pnlCookie.Visible = false; pnlLogin.Visible = true; } else { string BaseUserName = Cookie.Values["UserName"]; string BaseUserPassword = Cookie.Values["Password"]; string NickName = Cookie.Values["NickName"]; if (la.ChkAdminExit(BaseUserName, BaseUserPassword)) { lbNICK_NAME.Text = NickName; pnlCookie.Visible = true; pnlLogin.Visible = false; } else { pnlCookie.Visible = false; pnlLogin.Visible = true; } } }
public async void LoginSuccessfulWithAntiForgery() { var client = new Mock <IHttpClientProxy>(); var response = new HttpClientProxyResponse { StatusCode = HttpStatusCode.OK, Contents = "<html><body><h1>Hello World</h2></body></html>" }; client.Setup(x => x.SendAsync(It.Is <HttpClientProxyRequest>(y => y.Values.Any(z => z.Key == "Username" && z.Value == "Username") && y.Values.Any(z => z.Key == "Password" && z.Value == "Password") && y.Values.Any(z => z.Key == "__RequestVerificationToken" && z.Value == "Token1234")))) .Returns(Task.FromResult(response)); var antiForgery = new Mock <IAntiForgeryAction>(); antiForgery.Setup(x => x.GetToken(It.IsAny <string>())).Returns("Token1234"); var sut = new LoginAction(client.Object, antiForgery.Object); await sut.LoginAsync("Username", "Password"); Assert.True(sut.Successful); client.VerifyAll(); }
public void TestBothValidatorsReturnsTrue() { var reducer = new ReducerComposer <AppState>(); var loginAction = new LoginAction("", "", true); var anyActionLogicMock = new Moq.Mock <ILogic <AppState, Logic.AnyAction> >(); anyActionLogicMock.Setup(x => x.PreProcess(It.IsAny <IStore <AppState> >(), It.IsAny <AnyAction>())).ReturnsAsync(new PreProcessResult(true, loginAction)); anyActionLogicMock.Setup(x => x.Process(It.IsAny <Func <AppState> >(), It.IsAny <AnyAction>(), It.IsAny <IMultiDispatcher>())); var nextActionLogicMock = new Moq.Mock <ILogic <AppState, AnyAction> >(); nextActionLogicMock.Setup(x => x.PreProcess(It.IsAny <IStore <AppState> >(), It.IsAny <AnyAction>())).ReturnsAsync(new PreProcessResult(true, loginAction)); nextActionLogicMock.Setup(x => x.Process(It.IsAny <Func <AppState> >(), It.IsAny <AnyAction>(), It.IsAny <IMultiDispatcher>())); IStore <AppState> store = new Store <AppState>(reducer, AppState.InitialState).ConfigureLogic(config => { config.AddLogics(anyActionLogicMock.Object); config.AddLogics(nextActionLogicMock.Object); }); store.Dispatch(new LoginAction("Bob", "pwd", true)); nextActionLogicMock.Verify(x => x.PreProcess(It.IsAny <IStore <AppState> >(), It.IsAny <AnyAction>()), Times.Once()); nextActionLogicMock.Verify(x => x.Process(It.IsAny <Func <AppState> >(), It.IsAny <AnyAction>(), It.IsAny <IMultiDispatcher>()), Times.Once()); anyActionLogicMock.Verify(x => x.Process(It.IsAny <Func <AppState> >(), It.IsAny <AnyAction>(), It.IsAny <IMultiDispatcher>()), Times.Once()); }
private void mainWebBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { IHTMLDocument2 win = (IHTMLDocument2)this.mainWebBrowser.Document.DomDocument; // 流转控制 if (win.url.Equals(Constants.LOGIN_PAGE)) { LoginAction.tryLogin(this.mainWebBrowser); } else if (win.url.Equals(Constants.MAIN_MENU)) { this.mainWebBrowser.Navigate(Constants.APPLY_TEMPORARY_SEQUENCE_NUMBER_PAGE); } else if (win.url.Equals(Constants.APPLY_TEMPORARY_SEQUENCE_NUMBER_PAGE)) { // 重写js文件中的alert方法。将alert参数导出。 /* * win.parentWindow.execScript("var testparam='';function nalert(ss){testparam =ss;}", "javascript"); * win.parentWindow.execScript("window.alert=nalert;window.onerror=null;window.confirm=null;window.open=null;window.showModalDialog=null;", "javascript"); * * try * { * * win.parentWindow.execScript("window.alert=nalert;"); * win.parentWindow.execScript("alert(11);", "javascript"); * } * catch * { } * * // 启动timer * this.timer1.Enabled = true; * this.timer1.Tick += new System.EventHandler(this.timer1_Tick); */ // 调用填参方法 FillConfigurationAction f = new FillConfigurationAction(this.mainWebBrowser); f.tryFillConfiguration(); } /* * * win.parentWindow.execScript("var testparam='';function nalert(ss){testparam =ss;}", "javascript"); * win.parentWindow.execScript("window.alert=nalert;window.onerror=null;window.confirm=null;window.open=null;window.showModalDialog=null;", "javascript"); * win.parentWindow.execScript("alert(11);", "javascript"); * try * { * win.parentWindow.execScript("document.getElementById('iframemenupage').contentWindow.alert=nalert;"); * } * catch * { } * win = null; * * // 调用填参方法 * FillConfigurationAction f = new FillConfigurationAction(this.mainWebBrowser); * f.tryFillConfiguration(); * */ }
public static bool LoginAction_Update(LoginAction oLoginAction) { SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings.Get("ConnectionString")); conn.Open(); SqlCommand cmd = new SqlCommand("sp_LoginAction_Update", conn); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@SessionID", oLoginAction.WorkingSessionID); cmd.Parameters.AddWithValue("@LastActionDate", oLoginAction.LastActionDate); cmd.Parameters.AddWithValue("@SessionClosed", oLoginAction.isWorkingSessionClosed); try { cmd.ExecuteNonQuery(); conn.Close(); return(true); } catch (Exception ex) { conn.Close(); ErrorHandler pError = new ErrorHandler(); pError.addMessageToPoisonQueue(oLoginAction, ex); return(false); } }
public void LoginAction_AggregateException() { //Arrange var action = new LoginAction(_mockRepositoryTrue.Object, _mockUsService.Object, _mockValService.Object, _mockValManager.Object, _log); //Act and Assert Assert.ThrowsException <AggregateException>(() => action.ProcessAction(null).Result, "Parameter is null. Invalid value."); }
public static void SetUp() { _driver = new ChromeDriver(); _la = new LoginAction(_driver); _ca = new CadastrarAction(_driver); _driver.Navigate().GoToUrl("http://automationpractice.com/index.php?controller=my-account"); }
public LoginActionTest() { _sysUserBll = new Mock <ISysUserBLL>(); _sysUserRoleBll = new Mock <ISysUserRoleBLL>(); _sysUserLoginBll = new Mock <ISysUserLogBLL>(); _areaBll = new Mock <IAreaBLL>(); _action = new LoginAction(_sysUserBll.Object, _sysUserRoleBll.Object, _sysUserLoginBll.Object, _areaBll.Object); }
public async Task <IActionResult> Login([FromBody] LoginAction action) { try { return(Ok(await Mediator.Send(action))); } catch (UnauthorizedAccessException) { return(Unauthorized()); } }
public void AddItemToShopCart(User user, string itemName) { var loginAction = new LoginAction(); var homePageAction = loginAction.Authentication(user); homePageAction.MakeSearchOfItem(itemName); homePageAction.AddItemToShopCart(); Assert.IsTrue(homePageAction.IsShopCartDialogOpen(), "IsShopCartDialogOpen:"); homePageAction.CloseShopCartDialogOpen(); }
protected override Result <dynamic> ExecuteCore(ObjectContext context) { var user = this.RegisterUser(context); using (var cmd = new LoginAction()) { cmd.Username = this.Username; cmd.Password = this.Password; return(cmd.Execute(context)); } }
public void LoginAction_Successful() { //Arrange var action = new LoginAction(_mockRepositoryTrue.Object, _mockUsService.Object, _mockValService.Object, _mockValManager.Object, _log); //Act var result = action.ProcessAction(_userApi.UserLogin).Result; //Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(RepoModel.User)); }
private void MaterializeCurrentUser(string userName, string password) { _currentUser = _provider.GetUserByUserName(userName); if (_currentUser != null) { _action = new LoginAction(_currentUser, password); } else { _action = null; } }
public async Task <ResponseBase> Login([FromBody] LoginRequest request) { try { var action = new LoginAction(_sysUserBll, _sysUserRoleBll, _sysUserLogBll, _areaBll); return(await action.ProcessAction(HttpContext, request)); } catch (Exception ex) { Log.Error(request, ex, this.GetType()); return(ResponseBase.CodeError()); } }
public async void LoginWithNoUsernameThrowArguementException() { var client = new Mock <IHttpClientProxy>(); var antiForgery = new Mock <IAntiForgeryAction>(); var sut = new LoginAction(client.Object, antiForgery.Object); var ex = await Assert.ThrowsAsync <ArgumentNullException>(() => sut.LoginAsync(null, "Password") ); Assert.Contains("user", ex.Message); }
public void Action_NoException_WhenCredentialsNullOrEmptyOrFalse(LoginActionTestParameter parameter) { LoginAction loginAction = new LoginAction(parameter.context, parameter.user); var command = new Invoker <LoginAction>(loginAction); command.Invoke(); var emptyModel = new NewUserModel(); Assert.Equal(emptyModel.Name, loginAction.LoggedInUserData.Name); Assert.Equal(emptyModel.UserName, loginAction.LoggedInUserData.UserName); Assert.Equal(emptyModel.Surname, loginAction.LoggedInUserData.Surname); Assert.Equal(emptyModel.Email, loginAction.LoggedInUserData.Email); }
public async Task Defaults_To_Interactive_Login() { var armManagerMock = new Mock <IArmManager>(); var settingsMock = new Mock <ISettings>(); var action = new LoginAction(armManagerMock.Object, settingsMock.Object); var args = new string[0]; // Test action.ParseArgs(args); await action.RunAsync(); // Assert armManagerMock.Verify(m => m.LoginAsync(), Times.Once); }
public async Task Can_Login_With_Username_And_Password() { var armManagerMock = new Mock <IArmManager>(); var armTokenManager = new Mock <IArmTokenManager>(); var settingsMock = new Mock <ISettings>(); var action = new LoginAction(armManagerMock.Object, settingsMock.Object, armTokenManager.Object); var username = Guid.NewGuid().ToString(); var password = Guid.NewGuid().ToString(); var args = new [] { "-u", username, "-w", password }; // Test action.ParseArgs(args); await action.RunAsync(); }
/// <summary> /// Connect /// </summary> /// <param name="Current"></param> public void DoConnect(SignInfo Current) { if (string.IsNullOrEmpty(Current.LoginInfomation.UserName)) { Current.LoginInfomation.UserName = "******"; Current.LoginInfomation.Password = "******"; } Cursor = Cursors.WaitCursor; _currentSign = ControlService.SignCombo.Current; _IsDisconnection = false; LoginAction login = new LoginAction(); login.Perform(); Cursor = Cursors.Default; }
public void ResetLogin() { _action = null; _result = null; if (_provider != null) { if (_currentUser != null) { _provider.CancelUserTokenSession(_token); } } _currentUser = null; _token = null; }
public async Task <ActionResult <LoginResult> > Login(LoginAction action, CancellationToken token) { var request = new LoginUserRequest { EmailAddress = action.EmailAddress, Password = action.Password }; var authToken = await this._requestContext.Send(request, token); await this._requestContext.CommitAsync(token); return(this.Ok(new LoginResult { Token = authToken.ToString() })); }
private IExploitRunner GetLoginBruteForce(int id) { throw new NotImplementedException("Unable to get running quick enough to be usable"); var poolCount = 1000; var loginPool = new LoginAction[poolCount]; for (int i = 0; i < poolCount; i++) { var sharedHttpClient = _serviceProvider.GetRequiredService <IHttpClientProxy>(); loginPool[i] = new LoginAction(sharedHttpClient, new AntiForgeryAction(sharedHttpClient)); } var exploit = new LoginBruteForce(loginPool); return(new ExploitRunner(id, exploit)); }
private void ProcessLogin(LoginAction action) { if (this.IsLoggingIn) { return; } this.App.StartLoading("Logging in..."); if (Program.UsesFallbackSteamAppId && this.loginFrame.IsSteam) { throw new Exception("Doesn't own Steam AppId on this account."); } Task.Run(async() => { if (Util.CheckIsGameOpen() && action == LoginAction.Repair) { App.ShowMessageBlocking("The game and/or the official launcher are open. XIVLauncher cannot repair the game if this is the case.\nPlease close them and try again.", "XIVLauncher"); Reactivate(); return; } if (Repository.Ffxiv.GetVer(App.Settings.GamePath) == Constants.BASE_GAME_VERSION && App.Settings.IsUidCacheEnabled == true) { App.ShowMessageBlocking( "You enabled the UID cache in the patcher settings.\nThis setting does not allow you to reinstall FFXIV.\n\nIf you want to reinstall FFXIV, please take care to disable it first.", "XIVLauncher Error"); this.Reactivate(); return; } IsLoggingIn = true; await this.Login(this.loginFrame.Username, this.loginFrame.Password, this.loginFrame.IsOtp, this.loginFrame.IsSteam, false, action); }).ContinueWith(t => { if (!App.HandleContinationBlocking(t)) { this.Reactivate(); } }); }
void sh_DataArrive(object sender, DataArriveEventArgs e) { if (e.Data.GetType() == typeof(LoginAction)) { LoginAction action = e.Data as LoginAction; e.StateObject.OperatorId = action.OperatorId; if (operatorSocketMap.ContainsKey(action.OperatorId)) { try { if (operatorSocketMap[action.OperatorId].Connected) { sh.SendPacket(operatorSocketMap[action.OperatorId], new OperatorForceLogoffEventArgs()); operatorSocketMap[action.OperatorId].Close(); } } catch (Exception ex) { Trace.TraceError("ForceLogoff Operator " + action.OperatorId + "failed : " + ex.Message); } operatorSocketMap[action.OperatorId] = e.StateObject.workSocket; } else { operatorSocketMap.Add(action.OperatorId, e.StateObject.workSocket); } } else if (e.Data.GetType() == typeof(LogoutAction)) { LogoutAction action = e.Data as LogoutAction; if (operatorSocketMap.ContainsKey(action.OperatorId)) { operatorSocketMap[action.OperatorId] = null; } } else if (e.Data.GetType() == typeof(HeartBeatAction)) { HeartBeatAction a = e.Data as HeartBeatAction; Operator op = OperatorService.GetOperatorById(a.OperatorId); if (op != null) { op.HeartBeatTime = DateTime.Now; } } }
public void LoginTest() { ILog log = LogManager.GetLogger("ErrorLog"); try { LoginAction.Login(); Assert.AreEqual(TestEnvironment.LoadJson().Welcome.Text, WebDriverUtils.TextChecker(LoginPageObjects.WelcomeText())); log.Info(System.Reflection.MethodBase.GetCurrentMethod()); log.Info(LoginPageObjects.SuccessMessage()); } catch (Exception ex) { log.Error(System.Reflection.MethodBase.GetCurrentMethod()); log.Error(LoginPageObjects.FailedMessage() + ex.Message); Assert.Fail(ex.Message); } }
public UserCredentials Post([FromBody] LoginAction loginAction) { IStoreUserService storeUserService = AutofacBootstapper.CurrentContainer.ResolveOptional <IStoreUserService>( new NamedParameter("companyId", loginAction.CompanyId), new NamedParameter("storeId", loginAction.StoreId), new NamedParameter("machineSn", loginAction.MachineSn), new NamedParameter("deviceSn", loginAction.DeviceSn) ); var result = storeUserService.Login(loginAction.Account, loginAction.Password, loginAction.Practice); var principal = new StoreUserPrincipal(result); Thread.CurrentPrincipal = principal; if (HttpContext.Current != null) { HttpContext.Current.User = principal; } return(result); }
protected void BTsubmit_Click(object sender, EventArgs e) { if (txtUsername.Text.Trim().Length == 0) { MessageBox("请输入用户名!"); return; } if (txtPassword.Text.Length == 0) { MessageBox("请输入密码!"); } string username=txtUsername .Text .Trim (); string password=txtPassword .Text; LoginAction act = new LoginAction(); User user = new User(); if (act.UserLogin(username, password)) { UserAct userAct = new UserAct(); user = userAct.GetByid(username); if (user.CanLogin == false) { // MessageBox("!"); Response.Write("0该用户已经被禁用!"); Response.End(); return; } //等级调整 if (string.IsNullOrEmpty(user.TuijianrenQQ) == false) { LimitAct limitAct = new LimitAct(); ICollection<Limit> limits = limitAct.GetAll().OrderBy(s => s.Integral).ToList(); Limit userLimit = limits.Where(s => s.Id == user.Limit).FirstOrDefault(); int oldLimit = user.Limit; int jiangli=0; JifenChangeAct changeAct = new JifenChangeAct(); int xiaofei = changeAct.Select(user.QQ).Where(s => s.Type == JifenChangeType.消费).Sum(s => s.Amount); int total = xiaofei + user.Jifen; foreach (var item in limits) { if (total > item.Integral && item.Integral > userLimit.Integral) { user.Limit = item.Id; jiangli =item .ShengjiJiangli ; } } if (oldLimit != user.Limit) { User tuijianren=userAct.GetByid(user.TuijianrenQQ); int hasJiangli = changeAct.Select(tuijianren.QQ).Where (s=>s.Type ==JifenChangeType .被推荐人升级奖励 && s.FromQQ ==user.QQ ).Sum (s=>s.Amount ) ; tuijianren.Jifen += (jiangli-hasJiangli ); try { userAct.Edit(tuijianren); userAct.Edit(user); changeAct.Add(tuijianren.QQ, jiangli, JifenChangeType.被推荐人升级奖励, true,user .QQ); } catch (Exception ex) { MessageBox(ex.Message); } } } Response.Cookies["jifenqq"].Value = "164981897"; Response.Write("1登录成功!"); Response.End(); // Response.Redirect("Page/TuiguangQQ.aspx"); } else { //MessageBox("!"); Response.Write("0用户名或密码错误!"); Response.End(); } }