/// <summary> /// Initiates logging in with the current <see cref="IProvider"/> registered in the <see cref="ProviderManager"/>. /// </summary> /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> public async Task LoginAsync() { if (UserDetails != null) { return; } var provider = ProviderManager.Instance.GlobalProvider; if (provider != null) { await provider.LoginAsync(); if (provider.State == ProviderState.SignedIn) { // TODO: include user details? LoginCompleted?.Invoke(this, new EventArgs()); } else { LoginFailed?.Invoke(this, new EventArgs()); } LoadData(); } }
private async void LoginButton_Click(object sender, RoutedEventArgs e) { try { var user = await Models.User.Login(PhoneTextBox.Text, CodePasswordBox.Password); if (user != null) { LoginSucceed?.Invoke(this, new LoginEventArgs() { user = user, isSuccess = true }); //把按钮自身作为参数传递 } else { LoginFailed?.Invoke(this, new LoginEventArgs() { isSuccess = false }); } } catch (Exception excep) { LoginFailed?.Invoke(this, new LoginEventArgs() { isSuccess = false, message = excep.Message }); } }
Handle(LoginSubmit command, TypedMessageResponse <string> response) { //var authenticated = _userCredentialRepository.Authenticate(command.UserName, command.Password); //if (authenticated) if (command.UserName.Equals("admin", StringComparison.OrdinalIgnoreCase) && command.Password.Equals("admin")) { var factory = new CorePrincipalFactory(); var principal = factory.CreatePrincipal(command.UserName); CorePrincipal.CurrentPrincipal = principal; new CoreFormsAuthentication().SetCookieFromPrincipal(principal); response.Data = "Thanks for logging in " + command.UserName; } else { string message = "Invalid username or password"; var loginFailedEvent = new LoginFailed { OccurredAt = DateTime.Now, PasswordSupplied = command.Password, UserNameSupplied = command.UserName, ResponseText = message }; EventAggregator.Instance.Publish <LoginFailed>(loginFailedEvent); response.Data = message; } return(response); }
private async void Login() { RaiseCanExecuteChanged(); SimpleUser user; try { using (ProgressProvider.StartProgress()) { user = await _signalHelperFacade.LoginSignalHelper.Login(Username, Password).ConfigureAwait(true); } } catch (LoginFailedException e) { LoginFailed?.Invoke(new LoginFailedEventArgs(e.Message)); return; } finally { RaiseCanExecuteChanged(); } LoggedIn = true; LoginSucceeded?.Invoke(new LoginSucceededEventArgs(user)); Application.Current.Dispatcher.Invoke(RaiseCanExecuteChanged); }
public static void Receive(LoginFailed @event) { var message = @event.ResponseText; var userNameSupplied = @event.UserNameSupplied; var passwordSupplied = @event.PasswordSupplied; var occuredAt = @event.OccurredAt; }
public void SetResult(int status) { Authenticated = status == 0; try { switch (status) { case LOGIN_SUCCESS: LoginSuccess?.Invoke(this, EventArgs.Empty); return; case LOGIN_INVALID: LoginFailed?.Invoke(this, new LoginFailedEventArgs(false)); return; case LOGIN_BANNED: LoginFailed?.Invoke(this, new LoginFailedEventArgs(true)); return; } } finally { Interlocked.CompareExchange(ref activeAuthRequest, 0, 1); } }
private void RaiseLoginFailed(LoginResult loginResult) { if (LoginFailed != null) { LoginFailed.Invoke(this, loginResult); } }
private async void LoadData() { var provider = ProviderManager.Instance.GlobalProvider; if (provider == null) { return; } if (provider.State == ProviderState.SignedIn) { try { // https://github.com/microsoftgraph/microsoft-graph-toolkit/blob/master/src/components/mgt-login/mgt-login.ts#L139 // TODO: Batch with photo request later? https://github.com/microsoftgraph/msgraph-sdk-dotnet-core/issues/29 UserDetails = await provider.Graph.Me.Request().GetAsync(); } catch (Exception e) { LoginFailed?.Invoke(this, new LoginFailedEventArgs(e)); } } else if (provider.State == ProviderState.SignedOut) { UserDetails = null; // What if this was user provided? Should we not hook into these events then? } else { // Provider in Loading state return; } IsLoading = false; }
/// <summary> /// Initiates logging in with the current <see cref="IProvider"/> registered in the <see cref="ProviderManager"/>. /// </summary> /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> public async Task LoginAsync() { if (UserDetails != null) { return; } var provider = ProviderManager.Instance.GlobalProvider; if (provider != null) { try { await provider.LoginAsync(); if (provider.State == ProviderState.SignedIn) { // TODO: include user details? LoginCompleted?.Invoke(this, new EventArgs()); LoadData(); } else { LoginFailed?.Invoke(this, new LoginFailedEventArgs(new TimeoutException("Login did not complete."))); } } catch (Exception e) { LoginFailed?.Invoke(this, new LoginFailedEventArgs(e)); } } }
private async void LoginAsync(PasswordBox passwordBox) { try { IsLoading = true; Boolean result = await _service.LoginAsync(UserName, passwordBox.Password); if (result) { LoginSucceeded?.Invoke(this, EventArgs.Empty); } else { LoginFailed?.Invoke(this, EventArgs.Empty); } } catch (Exception ex) when(ex is NetworkException || ex is HttpRequestException) { OnMessageApplication($"Unexpected error occured! ({ex.Message})"); } finally { IsLoading = false; } }
private void ConnectFailed( ) { ConnectFailedCount++; Interlocked.Exchange(ref isConnecting, 0); LoginFailed?.Invoke(ConnectFailedCount); LogNet?.WriteDebug(ToString( ), "Connected Failed, Times: " + ConnectFailedCount); }
public async void Login() { Busy = true; if (string.IsNullOrEmpty(Email) || string.IsNullOrEmpty(Password)) { LoginFailed?.Invoke(this, "Email and Password are required."); Busy = false; return; } var result = await Services.Host.AuthService.Authenticate(Email, Password); if (result.Success) { LoginSuccess?.Invoke(this, EventArgs.Empty); Busy = false; return; } LoginFailed?.Invoke(this, result.error_description); Busy = false; }
public async Task <bool> LoginUser(string userName, string password) { var result = false; try { var api = new IdentityApi( "https://localhost:6001", await TokenService.Instance.GetAccessTokenAsync()); var validUser = await api.ValidateUser(userName, password); if (validUser) { var authUser = await api.GetAuthenticatedUser(userName); if (authUser != null) { this.CurrentPrincipal = authUser; LoggedIn?.Invoke(this, EventArgs.Empty); result = true; } } else { LoginFailed?.Invoke(this, EventArgs.Empty); } } catch (Exception e) { this.Log().LogError(e.Message); } return(result); }
public async Task UsersAreLockedOutAccordingToAfterMaxLoginAttemptsFail() { string userId = "test"; string emailAddress = "*****@*****.**"; string name = "John Doe"; string password = "******"; _eventStore.WithEvents("test", "user-test", new UserCreated(userId, emailAddress, name), new EmailAddressVerificationRequested(userId, emailAddress, _token), new PasswordResetTokenCreated(userId, _token), new EmailAddressVerified(userId, emailAddress), new PasswordSet(userId, _passwordHasher(password)) ); LoginFailed failedLogin = new LoginFailed(userId, _now); failedLogin.AddMetadataValue("userVersion", _eventStore.Streams["user-test"].Count - 1); _eventStore.WithEvents(userId, "userLogin-test", failedLogin, failedLogin); Guid commandId = Guid.NewGuid(); Result result = await _handler.Execute(new LoginUser(commandId, userId, "not the password")); Assert.Equal(LoginResult.LockedOut, result.Value <LoginResult>(commandId)); _eventStore.AssertEvents(userId, "userLogin-test", new LoginFailed(userId, _now), new AccountLockedOut(userId, _lockoutPolicy())); }
/// <summary> /// 登陆到百度 /// </summary> /// <param name="username">用户名</param> /// <param name="password">密码</param> /// <returns>返回登陆是否成功</returns> /// <remarks>no throw, return false if failed</remarks> public bool Login(string username, string password) { Tracer.GlobalTracer.TraceInfo("BaiduOAuth.Login called: username="******", password=*"); _username = username; _password = password; try { // #1 HTTP request: token request _get_token(); // #2 HTTP request: login check var captcha_data = _v2_api__logincheck(_token, username); //需要验证码并且验证码为空时,引发CaptchaRequiredException if (!string.IsNullOrEmpty(captcha_data.codestring) && _verifycode == null) { _codestring = captcha_data.codestring; _vcodetype = captcha_data.vcodetype; LoginCaptchaRequired?.Invoke(); throw new CaptchaRequiredException(); } // #3 HTTP request: get public key (RSA password encryption) var rsa_key = _v2_getpublickey(_token, _get_guid()); // #4 HTTP request: post login var login_result = _v2_api__login(_token, _codestring, _get_guid(), username, password, rsa_key.key, rsa_key.pubkey, _verifycode); //对登陆结果返回的验证码字段进行赋值 if (!string.IsNullOrEmpty(login_result.vcodetype)) { _vcodetype = login_result.vcodetype; } if (!string.IsNullOrEmpty(login_result.codestring)) { _codestring = login_result.codestring; } switch (login_result.errno) { case "0": //登陆成功 LoginSucceeded?.Invoke(); return(true); case "257": LoginCaptchaRequired?.Invoke(); throw new CaptchaRequiredException(); default: _failed_code = int.Parse(login_result.errno); _failed_reason = ""; throw new LoginFailedException("Login failed with response code " + login_result.errno); } } catch (Exception ex) { Tracer.GlobalTracer.TraceError(ex); LoginFailed?.Invoke(); return(false); } }
public LoginFailedView(LoginFailed data) { if (data == null) { throw new ArgumentNullException(nameof(data)); } Data = data; }
public async Task LoginAsync() { try { var opts = new OidcClientOptions { Authority = m_Authority, ClientId = m_ClientId, ClientSecret = m_ClientSecret, RedirectUri = m_RedirectUrl, Scope = m_Scope, LoadProfile = m_LoadProfile, Flow = OidcClientOptions.AuthenticationFlow.AuthorizationCode, ResponseMode = OidcClientOptions.AuthorizeResponseMode.Redirect, Policy = new Policy() { RequireAuthorizationCodeHash = false, RequireAccessTokenHash = false } }; var client = new OidcClient(opts); var loginRequest = new LoginRequest(); var state = await client.PrepareLoginAsync(); var authData = GetUserData(); LoginResult loginRes = null; if (authData.StayLoggedIn) { loginRes = await Login(client, state, true, authData.StayLoggedIn); } if (loginRes?.User == null) { loginRes = await Login(client, state, false, authData.StayLoggedIn); } if (loginRes.User != null) { LoggedIn?.Invoke(loginRes.User.Identity?.Name); } else { throw new Exception(loginRes.Error); } } catch (Exception ex) { LoginFailed?.Invoke(); throw new LoginFailedException(ex); } }
private void OnClick_btnLogin() { bool succeedLogin = LoginService.LoadUser(Address, Password); if (succeedLogin) { LoginSucceed?.Invoke(this, EventArgs.Empty); } else { LoginFailed?.Invoke(this, EventArgs.Empty); } }
/// <summary> /// See docs in <see cref="SoomlaProfile.Login"/> /// </summary> /// <param name="success">Callback function that is called if login was successful.</param> /// <param name="fail">Callback function that is called if login failed.</param> /// <param name="cancel">Callback function that is called if login was cancelled.</param> public override void Login(LoginSuccess success, LoginFailed fail, LoginCancelled cancel) { FB.LogInWithReadPermissions(this.loginPermissions, (ILoginResult result) => { if (result.Error != null) { SoomlaUtils.LogDebug (TAG, "LoginCallback[result.Error]: " + result.Error); fail(result.Error); } else if (!FB.IsLoggedIn) { SoomlaUtils.LogDebug (TAG, "LoginCallback[cancelled]"); cancel(); } else { success(); } }); }
public void Login() { string homepageResponse = httpManager.Get("http://www.darkorbit.com/"); Match match = Regex.Match(homepageResponse, "class=\"bgcdw_login_form\" action=\"(.*)\">"); if (!match.Success) { LoginFailed?.Invoke(this, EventArgs.Empty); return; } string loginResponse = httpManager.Post(WebUtility.HtmlDecode(match.Groups[1].ToString()), $"username={Username}&password={Password}"); match = Regex.Match(httpManager.lastURL, "https://(.*).darkorbit.bigpoint.com"); if (!match.Success) { match = Regex.Match(httpManager.lastURL, "https://(.*).darkorbit.com"); } if (!match.Success) { LoginFailed?.Invoke(this, EventArgs.Empty); return; } Server = match.Groups[1].ToString(); string mapResponse = httpManager.Get($"{match.Value}/indexInternal.es?action=internalMapRevolution"); match = Regex.Match(mapResponse, "{\"pid\":([0-9]+),\"uid\":([0-9]+)[\\w,\":]+sid\":\"([0-9a-z]+)\""); Match pid = Regex.Match(mapResponse, "basePath\": \"spacemap\",\"pid\": \"([0-9]+)"); if (!match.Success || !pid.Success) { LoginFailed?.Invoke(this, EventArgs.Empty); return; } InstanceID = int.Parse(pid.Groups[1].ToString()); UserID = int.Parse(match.Groups[2].ToString()); SID = match.Groups[3].ToString(); match = Regex.Match(mapResponse, "mapID\": \"([0-9]*)\""); Map = int.Parse(match.Groups[1].ToString()); LoginSucceed?.Invoke(this, EventArgs.Empty); }
/// <summary> /// See docs in <see cref="SoomlaProfile.Login"/> /// </summary> /// <param name="success">Callback function that is called if login was successful.</param> /// <param name="fail">Callback function that is called if login failed.</param> /// <param name="cancel">Callback function that is called if login was cancelled.</param> public override void Login(LoginSuccess success, LoginFailed fail, LoginCancelled cancel) { FB.Login(this.permissionsStr, (FBResult result) => { if (result.Error != null) { SoomlaUtils.LogDebug(TAG, "LoginCallback[result.Error]: " + result.Error); fail(result.Error); } else if (!FB.IsLoggedIn) { SoomlaUtils.LogDebug(TAG, "LoginCallback[cancelled]"); cancel(); } else { checkPermissions("publish_actions", "user_birthday"); FB.API("/me/permissions", Facebook.HttpMethod.GET, delegate(FBResult response) { // inspect the response and adapt your UI as appropriate // check response.Text and response.Error SoomlaUtils.LogWarning(TAG, "me/permissions " + response.Text); }); FB.API("/me?fields=id,name,email,first_name,last_name,picture", Facebook.HttpMethod.GET, (FBResult result2) => { if (result2.Error != null) { SoomlaUtils.LogDebug(TAG, "ProfileCallback[result.Error]: " + result2.Error); fail(result2.Error); } else { SoomlaUtils.LogDebug(TAG, "ProfileCallback[result.Text]: " + result2.Text); SoomlaUtils.LogDebug(TAG, "ProfileCallback[result.Texture]: " + result2.Texture); string fbUserJson = result2.Text; UserProfile userProfile = UserProfileFromFBJsonString(fbUserJson); SoomlaProfile.StoreUserProfile(userProfile, true); success(userProfile); } }); } }); }
public void OnEvent(SdkEvent sdkEvent) { if (sdkEvent.Event.Equals("Connected")) { Connected?.Invoke(this); } else if (sdkEvent.Event.Equals("ConnectionFailed")) { ConnectionFailed?.Invoke(this, sdkEvent.GetEventArgs <ConnectionFailedEventArgs>()); } else if (sdkEvent.Event.Equals("Disconnected")) { Disconnected?.Invoke(this); } else if (sdkEvent.Event.Equals("LoginSuccess")) { LoginSuccess?.Invoke(this, sdkEvent.GetEventArgs <LoginSuccessEventArgs>()); } else if (sdkEvent.Event.Equals("LoginFailed")) { LoginFailed?.Invoke(this, sdkEvent.GetEventArgs <LoginFailedEventArgs>()); } else if (sdkEvent.Event.Equals("RefreshTokenSuccess")) { RefreshTokenSuccess?.Invoke(this, sdkEvent.GetEventArgs <RefreshTokenSuccessEventArgs>()); } else if (sdkEvent.Event.Equals("RefreshTokenFailed")) { RefreshTokenFailed?.Invoke(this, sdkEvent.GetEventArgs <RefreshTokenFailedEventArgs>()); } else if (sdkEvent.Event.Equals("OneTimeKeyGenerated")) { OneTimeKeyGenerated?.Invoke(this, sdkEvent.GetEventArgs <OneTimeKeyGeneratedEventArgs>()); } else if (sdkEvent.Event.Equals("IncomingCall")) { var eventArgs = sdkEvent.GetEventArgs <IncomingCallEventArgs>(); eventArgs.Call = GetIncomingCall(eventArgs.callId); IncomingCall?.Invoke(this, eventArgs); } else { Debug.LogError($"Unknown Event '{sdkEvent.Event}'"); } }
/// <summary> /// 登录用户验证 /// </summary> /// <param name="account">账户</param> /// <param name="password">账户密码</param> /// <param name="loginInfo">登录信息</param> /// <returns></returns> private Result <Account> Login(Account account, string password, string ip) { //判断用户是否禁止登陆和密码匹配 if (!account.IsAllowLogin()) { return(Result <Account> .ReFailure(ResultCodes.AccountNotAllowedLogin)); } if (!account.HasPassword(password)) { //获取是否有登录失败信息 LoginFailed loginFailed = this.GetLoginFailedInfo(account.Username); loginFailed.Accumulative(); if (loginFailed.FailedCount >= this.maxLoginFailedCount) { return(Result <Account> .ReFailure(ResultCodes.AccountPasswordNotSameOverrun)); } return(Result <Account> .ReFailure(ResultCodes.AccountPasswordNotSame2.ToFormat((this.maxLoginFailedCount - loginFailed.FailedCount).ToString()))); } //生成访问Token List <Claim> claims = new List <Claim>(); claims.AddRange(new[] { new Claim(ClaimTypes.Role, "self"), new Claim(ClaimTypes.Role, "admin"), new Claim("name", account.Username), new Claim("nickname", account.Name), new Claim("sub", account.Id.ToString()), new Claim("auth_mode", loginType) }); var accessToken = _tokenGenerate.Generate(claims); //生成访问Token account.SetLoginInfo(new LoginInfo(ip, accessToken)); //记录登录日志 this._logLoginRecordService.Record(account, loginType); //移除登录失败记录 this.RemoveLoginFailedInfo(account.Username); return(Result <Account> .ReSuccess(account)); }
public LoginResult login(string username = null, string password = "", string steamguard = "", int timeout = 20000) { var source = new CancellationTokenSource(); source.CancelAfter(timeout); return(Task <LoginResult> .Run(() => { bool _loggedin = false; bool canceled = true; ManualResetEvent waitForResult = null; LoginResult result = LoginResult.Timeout; LoggedIn success = (sender) => { canceled = false; result = LoginResult.OK; _loggedin = true; waitForResult.Set(); }; LoginFailed failed = (sender, r) => { result = r; waitForResult.Set(); }; LoggedIn += success; LoginFailed += failed; int i = 0; do { canceled = true; waitForResult = new ManualResetEvent(false); sendCommand(username == null ? "login anonymous" : string.Format("login {0}{1}{2}", username, string.IsNullOrEmpty(" " + password) ? "" : " " + password, string.IsNullOrEmpty(" " + steamguard) ? "" : " " + steamguard)); waitForResult.WaitOne(timeout); i++; }while (!_loggedin & !canceled & !source.Token.IsCancellationRequested); source.Dispose(); LoggedIn -= success; LoginFailed -= failed; return result; }, source.Token).Result); }
/// <summary> /// See docs in <see cref="SoomlaProfile.Login"/> /// </summary> /// <param name="success">Callback function that is called if login was successful.</param> /// <param name="fail">Callback function that is called if login failed.</param> /// <param name="cancel">Callback function that is called if login was cancelled.</param> public override void Login(LoginSuccess success, LoginFailed fail, LoginCancelled cancel) { FB.Login(this.loginPermissionsStr, (FBResult result) => { if (result.Error != null) { SoomlaUtils.LogDebug(TAG, "LoginCallback[result.Error]: " + result.Error); fail(result.Error); } else if (!FB.IsLoggedIn) { SoomlaUtils.LogDebug(TAG, "LoginCallback[cancelled]"); cancel(); } else { this.fetchPermissions(() => { FB.API("/me?fields=id,name,email,first_name,last_name,picture", Facebook.HttpMethod.GET, (FBResult meResult) => { if (meResult.Error != null) { SoomlaUtils.LogDebug(TAG, "ProfileCallback[result.Error]: " + meResult.Error); fail(meResult.Error); } else { SoomlaUtils.LogDebug(TAG, "ProfileCallback[result.Text]: " + meResult.Text); SoomlaUtils.LogDebug(TAG, "ProfileCallback[result.Texture]: " + meResult.Texture); string fbUserJson = meResult.Text; UserProfile userProfile = UserProfileFromFBJsonString(fbUserJson); userProfile.AccessToken = FB.AccessToken; SoomlaProfile.StoreUserProfile(userProfile, true); success(userProfile); } }); }, (string errorMessage) => { fail(errorMessage); }); } }); }
/// <summary> /// See docs in <see cref="SoomlaProfile.Login"/> /// </summary> /// <param name="success">Callback function that is called if login was successful.</param> /// <param name="fail">Callback function that is called if login failed.</param> /// <param name="cancel">Callback function that is called if login was cancelled.</param> public override void Login(LoginSuccess success, LoginFailed fail, LoginCancelled cancel) { FB.Login(this.loginPermissionsStr, (FBResult result) => { if (result.Error != null) { SoomlaUtils.LogDebug(TAG, "LoginCallback[result.Error]: " + result.Error); fail(result.Error); } else if (!FB.IsLoggedIn) { SoomlaUtils.LogDebug(TAG, "LoginCallback[cancelled]"); cancel(); } else { success(); } }); }
public void ValidateUser() { try { ValidateUserCommand.IsEnabled = false; User user = _repository.Validate(CurrentUser.UserId, CurrentUser.Password); if (user != null) { SessionInfo si = SessionInfo.Instance; si.user = user; #if !Desktop WebDataClient.UpdateAuthToken(user.SessionToken); #endif StoreSessionInfoAsync(user); if (LoginSuccess != null) { LoginSuccess.ShowUI(); } } else { if (LoginFailed != null) { LoginFailed.ShowUI(); } ValidateUserCommand.IsEnabled = true; } } catch (Exception ex) { msgBox.ShowUI(ex.Message); } }
/// <summary> /// See docs in <see cref="SoomlaProfile.Login"/> /// </summary> /// <param name="success">Callback function that is called if login was successful.</param> /// <param name="fail">Callback function that is called if login failed.</param> /// <param name="cancel">Callback function that is called if login was cancelled.</param> public override void Login(LoginSuccess success, LoginFailed fail, LoginCancelled cancel) { FB.Login("email,publish_actions", (FBResult result) => { if (result.Error != null) { SoomlaUtils.LogDebug (TAG, "LoginCallback[result.Error]: " + result.Error); fail(result.Error); } else if (!FB.IsLoggedIn) { SoomlaUtils.LogDebug (TAG, "LoginCallback[cancelled]"); cancel(); } else { FB.API("/me/permissions", Facebook.HttpMethod.GET, delegate (FBResult response) { // inspect the response and adapt your UI as appropriate // check response.Text and response.Error SoomlaUtils.LogWarning(TAG, "me/permissions " + response.Text); }); FB.API("/me?fields=id,name,email,first_name,last_name,picture", Facebook.HttpMethod.GET, (FBResult result2) => { if (result2.Error != null) { SoomlaUtils.LogDebug (TAG, "ProfileCallback[result.Error]: " + result2.Error); fail(result2.Error); } else { SoomlaUtils.LogDebug(TAG, "ProfileCallback[result.Text]: "+result2.Text); SoomlaUtils.LogDebug(TAG, "ProfileCallback[result.Texture]: "+result2.Texture); string fbUserJson = result2.Text; UserProfile userProfile = UserProfileFromFBJsonString(fbUserJson); SoomlaProfile.StoreUserProfile (userProfile, true); success(userProfile); } }); } }); }
private void CustomLoginControl_LoginAttempt(object sender, LoginEventArgs e) { var user = Users.Where(x => x.CheckLogin(e.Login, e.Password)).SingleOrDefault(); if (user == null) { LoginFailed?.Invoke(this, new LoginFailureEventArgs() { Errors = new List <LoginFailureEventArgs.LoginError>() { new LoginFailureEventArgs.LoginError() { Field = LoginFields.All, ErrorMessage = "Wrong username or password" } } }); } else { LoginSuccess?.Invoke(this, EventArgs.Empty); } }
public void CostomLoginControl_LoginAttempt(object sender, LoginEventArgs e) { var user = users.Where(x => x.CheckLogin(e.Login, e.Password.ToString())).SingleOrDefault(); if (user == null) { LoginFailed?.Invoke(this, new LoginFailureEventArgs() { Errors = new List <LoginFailureEventArgs.LoginError>() { new LoginFailureEventArgs.LoginError() { Field = LoginFields.All, ErrorMessage = "Zły login lub hasło" } } }); } else { LoginSucces?.Invoke(this, EventArgs.Empty); this.Close(); } }
/// <summary> /// See docs in <see cref="SoomlaProfile.Login"/> /// </summary> public abstract void Login(LoginSuccess success, LoginFailed fail, LoginCancelled cancel);
/// <summary> /// See docs in <see cref="SoomlaProfile.Login"/> /// </summary> public override void Login(LoginSuccess success, LoginFailed fail, LoginCancelled cancel) { }
/// <summary> /// See docs in <see cref="SoomlaProfile.Login"/> /// </summary> /// <param name="success">Callback function that is called if login was successful.</param> /// <param name="fail">Callback function that is called if login failed.</param> /// <param name="cancel">Callback function that is called if login was cancelled.</param> public override void Login(LoginSuccess success, LoginFailed fail, LoginCancelled cancel) { FB.Login(this.loginPermissionsStr, (FBResult result) => { if (result.Error != null) { SoomlaUtils.LogDebug (TAG, "LoginCallback[result.Error]: " + result.Error); fail(result.Error); } else if (!FB.IsLoggedIn) { SoomlaUtils.LogDebug (TAG, "LoginCallback[cancelled]"); cancel(); } else { this.fetchPermissions(() => { FB.API("/me?fields=id,name,email,first_name,last_name,picture", Facebook.HttpMethod.GET, (FBResult meResult) => { if (meResult.Error != null) { SoomlaUtils.LogDebug (TAG, "ProfileCallback[result.Error]: " + meResult.Error); fail(meResult.Error); } else { SoomlaUtils.LogDebug(TAG, "ProfileCallback[result.Text]: "+meResult.Text); SoomlaUtils.LogDebug(TAG, "ProfileCallback[result.Texture]: "+meResult.Texture); string fbUserJson = meResult.Text; UserProfile userProfile = UserProfileFromFBJsonString(fbUserJson); SoomlaProfile.StoreUserProfile (userProfile, true); success(userProfile); } }); }, (string errorMessage) => { fail(errorMessage); }); } }); }
/// <summary> /// See docs in <see cref="SoomlaProfile.Login"/> /// </summary> public override void Login(LoginSuccess success, LoginFailed fail, LoginCancelled cancel) {}
public LoginCallback(LoginSuccessful successCallback, LoginFailed failedCallback) { this.successCallback = successCallback; this.failedCallback = failedCallback; }
private void OnLoginFailed(LoginFailed ev) { ShowLogin(); }