public void ExchangeDone(LoginClient client) { lock (Clients) Clients.Remove(client); OnLogin?.Invoke(client); }
public async void Login() { JobLoginAsync j = new JobLoginAsync(); j.username = emailField.text; j.password = passwordField.text; j.OnStart += () => { loginErrorText.gameObject.SetActive(false); }; j.OnError += (e) => { if (e == "auth") { loginErrorText.text = "Login failed, please try again"; loginErrorText.gameObject.SetActive(true); } }; j.OnResult += (SDKLoginResult result) => { PlayerPrefs.SetString("login", j.username); PlayerPrefs.SetString("password", j.password); PlayerPrefs.SetString("token", result.token); PlayerPrefs.SetString("server", serverField.text); m_Sdk.developerToken = result.token; loginErrorText.gameObject.SetActive(false); FadeOut(); OnLogin?.Invoke(); }; await j.RunJobAsync(); }
void LoginInvoke() { _timer.Change((long)Timeouts.Login, (long)Timeouts.Login); OnLogin?.Invoke(this, new AgentStateEventArgs { Mode = _mode }, _monitorId); }
public async Task LoginAsync(string login, string password, string loginPath) { var loginCredentials = new LoginCredentials(login, password); var loginJson = JsonConvert.SerializeObject(loginCredentials); var response = await Client.PostJsonAsync(loginPath, new StringContent(loginJson)); if (response.IsSuccessStatusCode) { var jwtJson = await response.Content.ReadAsStringAsync(); var jwt = JsonConvert.DeserializeObject <Jwt>(jwtJson); Token = jwt.Token; AutomaticLogout(jwt.Expires); IsLoggedIn = true; OnLogin?.Invoke(this, EventArgs.Empty); return; } if (response.StatusCode.Equals(HttpStatusCode.BadRequest)) { throw new ClientException(ErrorCodes.InvalidLoginCredentials); } }
/// <summary> /// Se ejecuta cuando el usuario le da click al boton de iniciar sesión /// </summary> private void On_LoginBtn_clicked(object o, EventArgs args) { //obtenemos las entradas var correo = LoginCorreo.Text; var clave = LoginClave.Text; //buscamos por un usuario con ese correo. Usuario user = DomiciliosApp.Instance.Compradores.Find(C => C.Correo == correo); user ??= DomiciliosApp.Instance.Vendedores.Find(V => V.Correo == correo); //si es null es porque no es encuentra ese usuario. if (user == null) { LoginCorreoExp.RevealChild = true; } else { //validamos la clave if (user.Clave == clave) { DomiciliosApp.ClienteActual = user; //llamamos el callback, si existe OnLogin?.Invoke(); } else { LoginClaveExp.RevealChild = true; } } }
public async void LoginAsync() { IsLoggingIn = true; Regex r = new Regex(@"^(([^<>()[\]\\.,;:\s@\""]+(\.[^<>()[\]\\.,;:\s@\""]+)*)|(\"".+\""))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$"); if (User.Emailadress != null && User.Password != null && r.IsMatch(User.Emailadress)) { if (await UserService.CheckUser(User as User) is User checkedUser) { Style = ""; OnLogin?.Invoke(checkedUser); } else { User.Password = null; Style = "border-color: red;"; StateHasChanged(); } } else { Style = "border-color: red;"; } IsLoggingIn = false; }
private void InitView() { UsernameInput = new TextField(14, 2, 40, ""); OkButton = new Button(3, 14, "Ok"); CancelButton = new Button(10, 14, "Cancel"); OkButton.Clicked += new Action(() => { var name = UsernameInput.Text.TrimSpace().ToString(); if (!string.IsNullOrEmpty(name)) { OnLogin?.Invoke(name); } }); CancelButton.Clicked += new Action(() => { CancelClicked?.Invoke(); }); Add( new Label(3, 2, "Login: "******"Password: "******"") { Secret = true }, OkButton, CancelButton); }
private async void LoginClick(object sender, RoutedEventArgs arg) { await Task.Run(() => { m_btnLogin.Dispatcher.Invoke(() => { m_btnLogin.IsEnabled = false; }); m_passwd = m_pwBox.Password; m_ssh = new SshClient(m_ip, m_user, m_passwd); m_ssh.ConnectionInfo.Timeout = TimeSpan.FromSeconds(3); m_scp = new ScpClient(m_ip, m_user, m_passwd); m_scp.ConnectionInfo.Timeout = TimeSpan.FromSeconds(3); try { m_ssh.Connect(); m_scp.Connect(); } catch (Exception e) { MessageBox.Show(e.Message); if (m_ssh.IsConnected) { m_ssh.Disconnect(); } m_btnLogin.Dispatcher.Invoke(() => { m_btnLogin.IsEnabled = true; }); return; } OnLogin?.Invoke(this, arg); }); }
private void PostLoginEvent() { if (!String.IsNullOrWhiteSpace(Txt_Username.Text) && !String.IsNullOrEmpty(Txt_Password.Password)) { Txt_loginFailure.Visibility = Visibility.Hidden; UserLoginEventArgs args = new UserLoginEventArgs() { Username = Txt_Username.Text, Password = Txt_Password.Password, AutomaticLogin = Chk_AutoLogin.IsChecked == true, RememberPassword = Chk_RememberPassword.IsChecked == true }; OnLogin?.Invoke(this, args); loginInfo.Message = "正在登录..."; } else if (String.IsNullOrWhiteSpace(Txt_Username.Text)) { loginInfo.Message = "请输入用户名!"; loginInfo.IsShown = true; } else if (String.IsNullOrEmpty(Txt_Password.Password)) { loginInfo.Message = "请输入密码!"; loginInfo.IsShown = true; } }
private void Login() { UserSession userSession = UserSession.GetInstance(); var userName = TBUserName.Text; string password = TBpassword.Text; User user = SearchUser(userName); if (user == null) { lblwarning.Text = @"User name is incorrect."; lblwarning.Show(); } else if (password == null || password == "") { lblwarning.Text = @"Password is empty."; lblwarning.Show(); } else if (userSession.Login(user, password)) { // dashboard if (OnLogin != null) { OnLogin.Invoke(this, new EventArgs()); } lblwarning.Text = @"Correct password."; lblwarning.Show(); } else { lblwarning.Text = @"Incorrect password."; lblwarning.Show(); } }
public async Task Init(Context context, string userId) { _context = context; _agoraRtmHandler = new AgoraRtmHandler(); _agoraRtmHandler.OnSignalReceived += (signal) => { Log($"Signal received from {signal.RtcPeerId}"); OnSignalReceived?.Invoke(signal); }; _rtmClient = RtmClient.CreateInstance(_context, AgoraTestConstants.AgoraAPI, _agoraRtmHandler); var rtmToken = await AgoraTokenService.GetRtmToken(userId); var loginCallback = new ResultCallback(); loginCallback.OnSuccessAction += (obj) => { UserName = userId; OnLogin?.Invoke(true); Log("Login Success"); }; loginCallback.OnFailureAction += (err) => { OnLogin?.Invoke(false); Log("Login Fail"); }; _rtmClient.Login(rtmToken, userId, loginCallback); }
private void btnLogIn_Click(object sender, RoutedEventArgs e) { SetButtonState(false); waitind.Visibility = Visibility.Visible; //show login animation LoginEventArgs arg = new LoginEventArgs(); foreach (BaseEdit x in logincontrols.Keys) { LoginParameter tmp = logincontrols[x]; if (tmp.Required && x.EditValue == null) { //set required label lciError.Visibility = Visibility.Visible; waitind.Visibility = Visibility.Hidden; lblError.Content = tmp.Name + " is required."; SetButtonState(true); return; } arg.Values.Add(new LoginParamValue { Param = tmp, Value = x.EditValue?.ToString() ?? "" }); if (tmp.ClearAfterEnter) { x.EditValue = null; } } lciError.Visibility = Visibility.Hidden; OnLogin?.Invoke(this, arg); }
private void Start() { player = FindObjectOfType <Player>(); if (!string.IsNullOrEmpty(player.Id)) { OnLogin?.Invoke(); } }
void OnUser(string packet) { me = JsonConvert.DeserializeObject <Profile>(packet); loggedIn = true; Debug.Log("Logged in as " + me.username); OnLogin?.Invoke(); CallEverythingLoaded(); }
private void handleData(DataPacket data) { switch (data.type) { case "LOGINRESPONSE": { DataPacket <LoginResponsePacket> d = data.GetData <LoginResponsePacket>(); if (d.data.status == "OK") { this._loggedIn = true; OnLogin?.Invoke(this._loggedIn, d.data.chatLog); Console.WriteLine("You are logged in!"); } else if (d.data.status == ("ERROR")) { this._loggedIn = false; OnLogin?.Invoke(this._loggedIn, d.data.chatLog); Console.WriteLine("Your username and/or password is not valid!"); } break; } case "REGISTERRESPONSE": { DataPacket <RegisterResponsePacket> d = data.GetData <RegisterResponsePacket>(); if (d.data.status == "OK") { this._registered = true; OnRegister?.Invoke(this._registered); Console.WriteLine("You are Registered"); this._loggedIn = true; OnLogin?.Invoke(this._loggedIn, d.data.chatLog); Console.WriteLine("You are logged in!"); } else if (d.data.status == ("ERROR")) { this._registered = false; OnRegister?.Invoke(this._registered); Console.WriteLine("Your username is already taken"); } break; } case "CHAT": { DataPacket <ChatPacket> d = data.GetData <ChatPacket>(); OnChatReceived?.Invoke($"{d.data.chatMessage}\r\n"); break; } default: Console.WriteLine("Type is not valid"); break; } }
public void Logout() { if (now.Name != "DefaultUser") { Logger.Log(ATSData.RunLog, now.Name + " 登出"); } now = DefaultUser; IsLogin = false; OnLogin.Invoke(this, new EventArgs()); }
public void SetCurrentSession(IApi api) { ; currentSession = api; if (api != null) { _store.SetSession(api.GetSessionInfo()); } SessionChanged?.Invoke(this, EventArgs.Empty); OnLogin?.Invoke(this, EventArgs.Empty); SessionChanged?.Invoke(this, EventArgs.Empty); }
private void Login() { CoroutineJobLogin j = new CoroutineJobLogin(); j.host = this; j.username = emailField.text; j.password = passwordField.text; j.OnStart += () => { loginErrorText.gameObject.SetActive(false); }; j.OnError += (UnityWebRequest request) => { if (request.responseCode == (long)HttpStatusCode.BadRequest) { loginErrorText.text = "Login failed, please try again"; loginErrorText.gameObject.SetActive(true); } }; j.OnResult += (SDKLoginResult result) => { if (result.error == "none") { PlayerPrefs.SetString("login", j.username); PlayerPrefs.SetString("password", j.password); PlayerPrefs.SetString("token", result.token); m_Sdk.developerToken = result.token; m_ToggleMappingMode?.EnableMappingMode(); if (m_ToggleMappingMode?.MappingUI != null) { m_ToggleMappingMode.MappingUI.GetComponent <MapperBase>().OnLogOut += OnLogOut; } loginErrorText.gameObject.SetActive(false); FadeOut(); OnLogin?.Invoke(); } else if (result.error == "auth") { loginErrorText.text = "Login failed, please try again"; loginErrorText.gameObject.SetActive(true); } }; StartCoroutine(j.RunJob()); }
public override void StreamParserOnStreamElement(object sender, Node e) { base.StreamParserOnStreamElement(sender, e); if (e is Handshake) { this.m_Authenticated = true; OnLogin?.Invoke(this); if (this.KeepAlive) { this.CreateKeepAliveTimer(); } } else if (e is Route) { OnRoute?.Invoke(this, e as Route); } else if (e is Protocol.XmppStreamError) { var streamErr = e as Protocol.XmppStreamError; switch (streamErr.Condition) { // Auth errors are important for the users here, so throw catch auth errors // in a separate event here case Protocol.XmppStreamErrorCondition.NotAuthorized: // Authentication Error OnAuthError?.Invoke(this, e as Element); break; default: OnStreamError?.Invoke(this, e as Element); break; } } else if (e is Message) { OnMessage?.Invoke(this, e as Message); } else if (e is Presence) { OnPresence?.Invoke(this, e as Presence); } else if (e is IQ) { OnIq?.Invoke(this, e as IQ); } }
public async Task Login(string username, string password) { using (var http = new HttpClient()) { var formContent = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("name", username), }); try { var req = await http.PostAsync(ServerAddress.LoginFormAddress, formContent); var result = await req.Content.ReadAsStringAsync(); var splittedResult = result.Split('|'); var intResult = Convert.ToInt32(splittedResult[0]); if (intResult != (int)LoginResult.Success) { OnLogin?.Invoke(LoginResult.Failed_Username, null, null, Gender.Female); return; } var hash = splittedResult[1]; var salt = splittedResult[2]; var isPasswordValid = HashSalt.VerifyPassword(password, hash, salt); if (isPasswordValid == false) { OnLogin?.Invoke(LoginResult.Failed_Password, null, null, Gender.Female); return; } var name = splittedResult[3]; var gender = (Gender)Enum.Parse(typeof(Gender), splittedResult[4]); var birthday = splittedResult[5]; OnLogin?.Invoke(LoginResult.Success, name, birthday, gender); } catch { OnLogin?.Invoke(LoginResult.Failed_MySQL, null, null, Gender.Female); } formContent.Dispose(); } }
private void FrameworkOnOnUpdateEvent(Framework framework) { if (this.Condition.Any() && this.lastConditionNone == true) { Log.Debug("Is login"); this.lastConditionNone = false; OnLogin?.Invoke(this, null); } if (!this.Condition.Any() && this.lastConditionNone == false) { Log.Debug("Is logout"); this.lastConditionNone = true; OnLogout?.Invoke(this, null); } }
public void TokenLogin(string authToken) { _accesskey = authToken; _thriftTransport.AccessKey = authToken; _thriftTransport.TargetUrl = URL.TalkService; //Don't know which should come first. _operationHandler.Start(); //Starts listening to events, then calls the OnLogin function. if (OnLogin != null) { OnLogin.Invoke(Result.OK); } return; }
public async Task Init(string userId) { var rtmToken = await AgoraTokenService.GetRtmToken(userId); _rtmKit.LoginByToken(rtmToken, userId, (status) => { var success = status == AgoraRtmLoginErrorCode.Ok; OnLogin?.Invoke(success); if (success) { UserName = userId; var rtmDelegate = new RtmDelegate(); rtmDelegate.OnMessageReceived += OmMessageReceived; _rtmKit.AgoraRtmDelegate = rtmDelegate; } }); }
protected override void Start() { base.Start(); _btnLogin.onClick.AddListener(() => { OnLogin?.Invoke(); }); _btnCreate.onClick.AddListener(() => { OnCreate?.Invoke(); }); _btnForgot.onClick.AddListener(() => { OnForgot?.Invoke(); }); }
private void RaiseOnResponse(string message) { var rawMessage = message.Split(':'); var type = rawMessage[0]; if (type.Contains("error")) { OnLoginError?.Invoke(rawMessage[2]); return; } if (type.Contains("shutdown")) { OnLoginError?.Invoke(rawMessage[2]); return; } if (type.Contains("login")) { OnLogin?.Invoke(); return; } if (type.Contains("logout")) { DestroyRunTask(); OnLogout?.Invoke(); return; } if (type.Contains("message")) { OnMessage?.Invoke(rawMessage[2]); return; } if (type.Contains("members")) { OnMembers?.Invoke(rawMessage[2]); return; } }
private async void LoginGo() { BeginSessionResponse result = null; try { result = await DiceWebAPI.BeginSessionAsync(Settings.Default.ApiSettings, _loginModel.Login, _loginModel.Password, int.Parse(_loginModel.GoogleCode == ""?"0": _loginModel.GoogleCode)); } catch (Exception ex) { } if (result != null) { OnLogin?.Invoke(this, new ResultLoginModel { Session = result.Session, ErrorResult = ErrorProcessing(result) }); } }
public async Task DoLogin() { _logger.Write("Loggin in..", LogLevel.INFO); try { await Client.Login.DoLogin(); IsLoggedIn = true; OnLogin?.Invoke(); _logger.Write("Successfull logged in", LogLevel.SUCC); } catch (Exception e) { _logger.Write($"Not logged in. [Exception] - {e.Message}", LogLevel.ERROR); IsLoggedIn = false; } }
private void _LoginButton_Click(object sender, RoutedEventArgs e) { _LoginButton.IsEnabled = false; _PasswordBox.IsEnabled = false; _UsernameBox.IsEnabled = false; Client.Authenticate(_UsernameBox.Text, _PasswordBox.Password).ContinueWith(task => { if (task.IsCompleted && task.Result) { OnLogin?.Invoke(this, EventArgs.Empty); } else { _LoginButton.IsEnabled = true; _PasswordBox.IsEnabled = true; _UsernameBox.IsEnabled = true; _PasswordBox.Password = ""; } }); }
public async Task Login() { _settingsHandler.Settings.LoginAuth = SelectedLoginType.LoginAuth; _settingsHandler.Settings.Username = UserName; _settingsHandler.Settings.Password = Password; _settingsHandler.Settings.SetRocketSettings(); _settingsHandler.SaveSettings(); _goBot.InitializeClient(); await _goBot.DoLogin(); if (_goBot.IsLoggedIn) { _lastLoginTime = DateTime.Now; _dispatcher.Start(); OnLogin?.Invoke(); GetPokemon?.Invoke(); } LoginCommand.RaiseCanExecuteChanged(); }
private void ProcessSocketResult(SocketPackage package) { var result = SocketResult.Parser.ParseFrom(package.Content); switch (result.Category) { case PackageCategory.Login: if (result.Code == ResultCode.Success) { StartHeart(); OnLogin?.Invoke(this, true, null); } else { OnLogin?.Invoke(this, false, result.Message); } break; //case PackageCategory.Ping: // Console.WriteLine("心跳成功"); // break; } }