public LoginController() { //LOGIN FactoryLogin = new LoginFactory(); JsonResponse = string.Empty; ORM = CapexInfraestructure.Utilities.Utils.Conectar(); }
private void Button_Click(object sender, RoutedEventArgs e) { LoginFactory factory = null; if (_loginControler.FindPatient(Username.Text, Password.Password) != null) { factory = new PatientLoginFactory(_loginControler.FindPatient(Username.Text, Password.Password)); } else if (_loginControler.FindSecretary(Username.Text, Password.Password) != null) { factory = new SecretaryLoginFactory(_loginControler.FindSecretary(Username.Text, Password.Password)); } else if (_loginControler.FindDoctor(Username.Text, Password.Password) != null) { factory = new DoctorLoginFactory(_loginControler.FindDoctor(Username.Text, Password.Password)); } else if (_loginControler.FindManager(Username.Text, Password.Password) != null) { factory = new ManagerLoginFactory(_loginControler.FindManager(Username.Text, Password.Password)); } if (factory != null) { ILoginer loginer = factory.GetLoginer(); loginer.Login(); this.Close(); return; } MessageBox.Show("Neuspesno logovanje!"); }
public void getLoginTest() { domain.Login login = LoginFactory.getLogin("Username", "Password"); Assert.AreEqual("Username", login.Username); Assert.AreEqual("Password", login.Password); }
private void LoadAdapters() { foreach (var login in Logins) { Composite.Add(LoginFactory.CreateInstance(login)); } }
public static Packet GetPacket(ConnectionState state, int packetId) { bool success; Packet outPacket; switch (state) { case ConnectionState.Handshake: success = HandshakeFactory.TryGetPacket(packetId, out outPacket); break; case ConnectionState.Status: success = StatusFactory.TryGetPacket(packetId, out outPacket); break; case ConnectionState.Login: success = LoginFactory.TryGetPacket(packetId, out outPacket); break; case ConnectionState.Play: success = PlayFactory.TryGetPacket(packetId, out outPacket); break; default: throw new ArgumentOutOfRangeException(nameof(state), state, null); } if (!success) { return(null); } outPacket.PacketId = packetId; return(outPacket); }
private void BtnLogin_Click(object sender, RoutedEventArgs e) { ForceValidation(); if (Validation.GetHasError(txtPasword) || Validation.GetHasError(txtuName)) { MessageBox.Show("Error Some Data is Missing", "ERROR"); return; } ResourceForm RFobj = new ResourceForm(); LoginFactory obj = new LoginFactory(); Admin_Table Aobj = new Admin_Table(); Aobj = obj.GetData(2); if (txtuName.Text == Aobj.A_UserName && txtPasword.Text == Aobj.A_Password) { this.Close(); RFobj.ShowDialog(); } else if (Aobj.A_UserName != txtuName.Text) { MessageBox.Show("User Name is Wrong Please Enter Again", "Error!"); } else if (txtPasword.Text != Aobj.A_Password) { MessageBox.Show("Password is Wrong Please Enter Again", "Error!"); } else { MessageBox.Show("Something is Wrong", "Error!"); } }
public object Login([FromBody] LoginAuthModel model, [FromServices] SigningConfigurations signingConfigurations, //Vem da configuração Startup [FromServices] TokenConfigurations tokenConfigurations //Vem da configuração Startup ) { var user = _mapper.Map <User>(model); try { using (var loginService = new LoginFactory(_serviceOptions).Build()) { var loggedUSer = loginService.EfetuarLogin(user); var identity = new ClaimsIdentity(new GenericIdentity(user.Login, "Login"), new[] { new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString("N")), new Claim(JwtRegisteredClaimNames.UniqueName, user.Login) }); DateTime dataCriacao = DateTime.Now; DateTime dataExpiracao = dataCriacao + TimeSpan.FromSeconds(tokenConfigurations.Seconds); var handler = new JwtSecurityTokenHandler(); var securityToken = handler.CreateToken(new SecurityTokenDescriptor { Issuer = tokenConfigurations.Issuer, Audience = tokenConfigurations.Audience, SigningCredentials = signingConfigurations.SigningCredentials, Subject = identity, NotBefore = dataCriacao, Expires = dataExpiracao }); var token = handler.WriteToken(securityToken); return(new { authenticated = true, idLoggedUser = loggedUSer.Id, created = dataCriacao.ToString("yyyy-MM-dd HH:mm:ss"), expiration = dataExpiracao.ToString("yyyy-MM-dd HH:mm:ss"), accessToken = token, message = "OK" }); } } catch (Exception ex) { return(new { authenticated = false, message = $"Falha ao autenticar:\n{ex.Message}" }); } }
public async Task Login_Post_ReturnsBadRequest() { var auth = LoginFactory.CreateAuth(string.Empty, string.Empty); var request = ServicesUtil.CreateRequestContent(auth); var response = await testContext.Client.PostAsync(endpointLogin, request); response.StatusCode.Should().Be(HttpStatusCode.BadRequest); }
public LoginPage() { InitializeComponent(); _loginFactory = new LoginFactory(); _loginFactory.HttpSucessHandler += LoginFactory_Sucess; _loginFactory.HttpFailorTimeOut += LoginFactory_TimeoutOrFail; Init(); }
public MainPage() { InitializeComponent(); _wayGetFactory = new WAYGetFactory(); _wayGetFactory.HttpSucessHandler += wayGetFactory_HttpSucess; _loginFactory = new LoginFactory(); _loginFactory.HttpSucessHandler += loginFactory_HttpSurcess; }
public void GetUserInfo() { if (Utils.Utils.GetAutoLoginSetting() && string.IsNullOrEmpty(Utils.Utils.GetUserNa()) != true && string.IsNullOrEmpty(Utils.Utils.GetUserpd()) != true) { LoginFactory _loginFactory = new LoginFactory(); _loginFactory.HttpFailHandler += _loginFactory_GetUserInfoFailed; _loginFactory.HttpSucessHandler += _loginFactory_GetUserInfoSuccess; _loginFactory.HttpTimeOutHandler += _loginFactory_GetUserInfoTimeout; _loginFactory.DownLoadDatas(new UserInfo(Utils.Utils.GetUserNa(), Utils.Utils.GetUserpd(), "")); } }
public MainPage() { this.InitializeComponent(); Window.Current.SizeChanged += Current_SizeChanged; _wayGetFactory = new WAYGetFactory(); _wayGetFactory.HttpSucessHandler += wayGetFactory_HttpSucess; _loginFactory = new LoginFactory(); _loginFactory.HttpSucessHandler += loginFactory_HttpSurcess; }
public async Task <HttpResponseMessage> PostData(LoginRequest request) { LoginFactory loginFactory = new LoginFactory(); var retValue = await loginFactory.PostData(request).ConfigureAwait(false); HttpResponseMessage response; response = Request.CreateResponse(HttpStatusCode.OK, retValue); return(response); //Test }
public async Task Login_Post_ReturnsInternalServerError() { var auth = LoginFactory.CreateAuth("usertest", "test123"); var request = ServicesUtil.CreateRequestContent(auth); var response = await testContext.Client.PostAsync(endpointLogin, request); response.StatusCode.Should().Be(HttpStatusCode.InternalServerError); var message = ServicesUtil.ReadResponseMessage(response); message.Should().Be(errorAccessDenied); }
internal static void Register <TPacket>(PacketDirection packetDirection, ConnectionState state, int packetId, Func <TPacket> createFunc) where TPacket : Packet { if (packetDirection == PacketDirection.ServerBound) { switch (state) { case ConnectionState.Handshake: HandshakeFactory.Register(packetId, createFunc); break; case ConnectionState.Status: StatusFactory.Register(packetId, createFunc); break; case ConnectionState.Login: LoginFactory.Register(packetId, createFunc); break; case ConnectionState.Play: PlayFactory.Register(packetId, createFunc); break; default: throw new ArgumentOutOfRangeException(nameof(state), state, null); } } else { switch (state) { case ConnectionState.Handshake: ServerHandshakeFactory.Register(packetId, createFunc); break; case ConnectionState.Status: ServerStatusFactory.Register(packetId, createFunc); break; case ConnectionState.Login: ServerLoginFactory.Register(packetId, createFunc); break; case ConnectionState.Play: ServerPlayFactory.Register(packetId, createFunc); break; default: throw new ArgumentOutOfRangeException(nameof(state), state, null); } } }
public void CreateLogin_CreatesValidModel() { var dateTime = new DateTime(2019, 01, 01); var login = new LoginDto { DateTime = dateTime }; var dto = LoginFactory.CreateLogin(login); Assert.NotNull(dto); Assert.Equal(dateTime, dto.DateTime); }
public UserLogin() { this.InitializeComponent(); this.Loaded += UserLogin_Loaded; _popUp = new Popup(); _popUp.IsLightDismissEnabled = false; _popUp.Opened += _popUp_Opened; closeSB.Completed += closeSB_Completed; _loginFactory = new LoginFactory(); _loginFactory.HttpSucessHandler += LoginFactory_Sucess; _loginFactory.HttpFailHandler += LoginFactory_Fail; _loginFactory.HttpTimeOutHandler += LoginFactory_TimeOut; Init(); }
private async Task Login(Login login) { try { var adapter = LoginFactory.CreateInstance(login); App.AppManager.Composite.InUse = adapter; if (login == null) { throw new NullReferenceException("Login is null."); } if (await adapter.Login()) { if (!App.AppManager.Contains(login)) { App.AppManager.AddLogin(login); } DialogResult = true; Close(); } else { if (App.CurrentApp.HasError) { while (App.CurrentApp.Errors.Any()) { var error = App.CurrentApp.Errors.FirstOrDefault(); MessageBox.Show(error, "Error", MessageBoxButton.OK); App.CurrentApp.Errors.Remove(error); } } else { MessageBox.Show("A error ocurred, please try again in a few seconds " + "or contact the support", "Error", MessageBoxButton.OK); } } } catch (NullReferenceException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK); } }
public void CreateLoginDto_CreatesValidDto() { var userName = "******"; var user = new User { Name = userName }; var dateTime = new DateTime(2019, 01, 01); var login = new Login { DateTime = dateTime, User = user }; var dto = LoginFactory.CreateLoginDto(login); Assert.NotNull(dto); Assert.Equal(dateTime, dto.DateTime); }
private void btn_login_Click(object sender, EventArgs e) { if (this.tb_operator.Text == String.Empty || this.tb_purchase_no.Text == String.Empty) { return; } _operator = new DataTable(); _operator.Columns.Add("operator_name"); _operator.Columns.Add("purchase_no"); _operator.Columns.Add("operator_id"); _operator.Columns.Add("purchase_id"); _operator.Columns.Add("work_station_id"); _operator.Columns.Add("site"); DataRow newrow = _operator.NewRow(); newrow["operator_name"] = this.tb_operator.Text.Trim(); newrow["purchase_no"] = this.tb_purchase_no.Text.Trim(); if (MainWindow.m_enable_mysql) { _operator.Rows.Add(newrow); try { LoginFactory.Operator_Login(); } catch (Exception ex) { common.m_log.Add(ex.Message, LogHelper.MessageType.ERROR); } } else { newrow["operator_id"] = -1; newrow["purchase_id"] = -1; newrow["work_station_id"] = -1; newrow["site"] = "unknown"; _operator.Rows.Add(newrow); } this.DialogResult = DialogResult.OK; this.Close(); }
/// <summary> /// 实现多种登录模式:1.Session 2.Cookie 3.Cache 在WebConfig中配置 /// </summary> public void login() { try { string msg = ""; ArrayList arrays = new ArrayList(); //检查记录登录次数 if ((ctx.Session["PassErrorCount"] != null) && (ctx.Session["PassErrorCount"].ToString() != "")) { int PassErroeCount = Convert.ToInt32(ctx.Session["PassErrorCount"]); if (PassErroeCount > 3) { msg = "登录尝试错误次数超过3次"; arrays.Add(msg); arrays.Add(false); } } //检查验证码 else if (Md5.md5(ctx.Request["checkcode"].ToString().ToLower(), 16).ToString() != HttpContext.Current.Session["diana_session_verifycode"].ToString()) { msg = "所填写的验证码与所给的不符 !"; arrays.Add(msg); arrays.Add(false); } else { LoginFactory login = new LoginFactory(ctx, accctx); arrays = login.GetLoginType().login(); } WriteBackHtml((string)arrays[0], (bool)arrays[1]); } catch (Exception ex) { WriteBackHtml(ex.Message.ToString(), false); } }
public async Task Login_Post_ReturnsOk() { #region Passo 1 - Criar uma conta de usuário var usuario = UsuarioFactory.CreateUsuario; var requestCreate = ServicesUtil.CreateRequestContent(usuario); var responseCreate = await testContext.Client.PostAsync(endpointUsuario, requestCreate); responseCreate.StatusCode.Should().Be(HttpStatusCode.OK); #endregion #region Passo 2 - Autenticar o usuário var auth = LoginFactory.CreateAuth(usuario.Login, usuario.Senha); var requestLogin = ServicesUtil.CreateRequestContent(auth); var responseLogin = await testContext.Client.PostAsync(endpointLogin, requestLogin); responseLogin.StatusCode.Should().Be(HttpStatusCode.OK); #endregion }
internal static void Register <TPacket>(ConnectionState state, int packetId, Func <TPacket> createFunc) where TPacket : Packet { switch (state) { case ConnectionState.Handshake: HandshakeFactory.Register(packetId, createFunc); break; case ConnectionState.Status: StatusFactory.Register(packetId, createFunc); break; case ConnectionState.Login: LoginFactory.Register(packetId, createFunc); break; case ConnectionState.Play: PlayFactory.Register(packetId, createFunc); break; default: throw new ArgumentOutOfRangeException(nameof(state), state, null); } }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { if (!(e.NavigationMode == System.Windows.Navigation.NavigationMode.Back)) { try { _validation = Convert.ToBoolean(NavigationContext.QueryString["validation"]); } catch (KeyNotFoundException) { _validation = false; } if (_validation) { InitElement(); NavigationService.RemoveBackEntry(); } else { //从其它页面过来,没有验证 if (Utils.Utils._isValidatedFromServer) { InitElement(); } else if (!string.IsNullOrEmpty(Utils.Utils.GetUserNa()) && !string.IsNullOrEmpty(Utils.Utils.GetUserpd())) { _loginFactory = new LoginFactory(); _loginFactory.HttpFailHandler += _loginFactory_GetUserInfoFailed; _loginFactory.HttpSucessHandler += _loginFactory_GetUserInfoSuccess; _loginFactory.HttpTimeOutHandler += _loginFactory_GetUserInfoTimeout; _loginFactory.DownLoadDatas(new UserInfo(Utils.Utils.GetUserNa(), Utils.Utils.GetUserpd(), "")); } } } }
public void CheckLogin() { string msg = string.Empty; //检查记录登录次数 if ((this.ctx.Session["PassErrorCount"] != null) && (this.ctx.Session["PassErrorCount"].ToString() != "")) { //获取错误登入次数 int PassErroeCount = Convert.ToInt32(this.ctx.Session["PassErrorCount"]); if (PassErroeCount > 3) { msg = "登录尝试错误次数超过3次"; this.Content(msg); WriteBackHtml(msg, false); return; } } /// 检查验证码 if ((this.ctx.Request["code"] != null) && (this.ctx.Request["code"].ToString() != "")) { if (Md5.md5(ctx.Request["code"].ToString().ToLower(), 16).ToString().ToLower() != this.ctx.Session["Athena_session_verifycode"].ToString().ToLower()) { msg = "验证码填写错误 !"; WriteBackHtml(msg, false); return; } } string userName = this.ctx.Request["username"]; string passWord = this.ctx.Request["password"]; AccountsPrincipal accctx = AccountsPrincipal.ValidateLogin(userName, passWord); string loginpattern = ConfigurationManager.AppSettings["LoginPattern"]; LoginFactory loginfactory = new LoginFactory(); Login lo = loginfactory.GetLoginType(loginpattern); if (lo.IsLoginPatternMessageExist()) { this.ctx.User = accctx; this.ctx.Session["accctx"] = accctx; lo.ClearLoginPattern(); msg = "登录成功,页面跳转中!"; WriteBackHtml(msg, true);//在页面上可以以红字提醒,JS直接direct跳转到下一个链接 } else { if (accctx == null)//登录信息不对 { msg = "登陆失败: " + userName; if ((this.ctx.Session["PassErrorCount"] != null) && (this.ctx.Session["PassErrorCount"].ToString() != "")) { int PassErroeCount = Convert.ToInt32(this.ctx.Session["PassErrorCount"]); this.ctx.Session["PassErrorCount"] = PassErroeCount + 1; } else { this.ctx.Session["PassErrorCount"] = 1; } } else { lo.SetLoginPatternMessage(userName, passWord); //把当前用户对象实例赋给Context.User,这样做将会把完整的用户信息加载到ASP.NET提供的验证体系中 this.ctx.User = accctx; this.ctx.Session["accctx"] = accctx; msg = "登录成功,页面跳转中!"; WriteBackHtml(msg, true);//在页面上可以以红字提醒,JS直接direct跳转到下一个链接 } } }
private void LoginClickHandle() { bool tem = false; CheckTbUserId(); tem = _isPass; CheckTbPassword(); if (_isPass && tem) { LoadingWait.Visibility = Visibility.Visible; _loginFactory = new LoginFactory(); _loginFactory.HttpFailHandler += _loginFactory_GetUserInfoFailed; _loginFactory.HttpSucessHandler += _loginFactory_GetUserInfoSuccess; _loginFactory.DownLoadDatas(new UserInfo(xTbUserId.Text, xTbPassword.Password, "")); _password = xTbPassword.Password; } }