public async Task <AuthenticationResult> SignInAsync(SignInArgs signInArgsArgs, CancellationToken cancellationToken = default(CancellationToken)) => await Task.Run(async() => { AuthenticationResult authenticationResult = null; string url = BaseSingleton <GlobalSetting> .Instance.RestEndpoints.IdentityEndpoints.SignInEndPoint; try { authenticationResult = await _requestProvider.PostAsync <AuthenticationResult, SignInArgs>(url, signInArgsArgs); if (authenticationResult != null && authenticationResult.IsSucceed) { await SetupProfileAsync(authenticationResult); } } catch (ConnectivityException ex) { throw ex; } catch (HttpRequestExceptionEx ex) { throw ex; } catch (Exception ex) { Debug.WriteLine($"ERROR:{ex.Message}"); Debugger.Break(); } return(authenticationResult); }, cancellationToken);
private async void Account_OnSignInComplete(object sender, SignInArgs e) { if (!e.IsSignedIn) { var isInternetConnected = await RestService.Instance.GetIsConnected(); if (isInternetConnected) { if (e.SignedInError.Length > 0) { await Application.Current.MainPage.DisplayAlert( (e.ErrorType == SignInAErrorType.AccountCreationError ? "Account Creation " : "Login ") + "Error", e.SignedInError, "OK"); } var registerModel = ((Cloud)Application.Current.BindingContext).Register; if (registerModel.IsLoading) { registerModel.IsLoading = false; } return; } } await loadMainPage(); }
public override void Process(SignInArgs args) { try { // get current user string username = args.User.InnerUser.Profile.Email; GetUserRequest request = new GetUserRequest(username); GetUserResult user = _customerServiceProvider.GetUser(request); if (!user.Success || user.CommerceUser == null) { // if user isn't a customer, run customer create pipeline string password = Guid.NewGuid().ToString(); CreateUserRequest createUserRequest = new CreateUserRequest(username, password, username, _storefrontContext.CurrentStorefront.ShopName); CreateUserResult createUserResult = _customerServiceProvider.CreateUser(createUserRequest); } // identify commerce user and merge anonymous cart Cart result = _cartManager.GetCurrentCart(_visitorContext, _storefrontContext, false).Result; Tracker.Current.CheckForNull().Session.IdentifyAs("CommerceUser", username); _visitorContext.UserJustLoggedIn(); _cartManager.MergeCarts(_storefrontContext.CurrentStorefront, _visitorContext, _visitorContext.CustomerId, result); } catch (Exception ex) { // log error Sitecore.Diagnostics.Log.Error($"Failed to create a customer for external user login {args.User.UserName}. {ex.Message}", this); } }
protected virtual void OnSignIn(SignInArgs e) { if (SignIn != null) { SignIn(this, e); } }
public Library SignIn([FromBody] SignInArgs args) { using (var db = new favlEntities()) { var librarian = db.Librarians.FirstOrDefault(l => l.Username == args.username); if (librarian == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } if (!PW.Verify(args.password, librarian.PasswordHash, librarian.PasswordSalt)) { throw new HttpResponseException(HttpStatusCode.Unauthorized); } return(new Library { Id = librarian.Library.Id, Name = librarian.Library.Name, Village = librarian.Library.Village, Country = librarian.Library.Country }); } }
public override Task InitializeAsync(object navigationData) { if (navigationData is SignInArgs signInArgs) { _signInArgsArgs = signInArgs; } return(base.InitializeAsync(navigationData)); }
private void btnCancel_Click(object sender, EventArgs e) { SignInArgs sArgs = new SignInArgs(); //MessageBox.Show(Common.GetMessage("INF0018"), Common.GetMessage("5008"), //MessageBoxButtons.OK, MessageBoxIcon.Information); sArgs.IsSuccess = false; OnSignIn(sArgs); this.Close(); }
private void btnOk_Click(object sender, EventArgs e) { try { string userName = txtUserCode.Text.Trim(); string password = txtPassword.Text.Trim(); if (userName == string.Empty) { // Show Message MessageBox.Show(Common.GetMessage("INF0050"), Common.GetMessage("5007"), MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (password == string.Empty) { // Show Message MessageBox.Show(Common.GetMessage("INF0051"), Common.GetMessage("5007"), MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { //Sign in SignInArgs sArgs = new SignInArgs(); if (AuthenticationComponent.BusinessObjects.Authenticate.LogInUser(userName, password, CoreComponent.Core.BusinessObjects.Common.LocationCode)) { sArgs.IsSuccess = true; OnSignIn(sArgs); this.Close(); } else { MessageBox.Show(Common.GetMessage("INF0018"), Common.GetMessage("5008"), MessageBoxButtons.OK, MessageBoxIcon.Information); sArgs.IsSuccess = false; OnSignIn(sArgs); } } } catch (Exception ex) { MessageBox.Show(Common.GetMessage("10002"), Common.GetMessage("30007"), MessageBoxButtons.OK, MessageBoxIcon.Error); Common.LogException(ex); } }
private async void Account_OnSignInComplete(object sender, SignInArgs e) { var cloud = (PlayOnCloud.ViewModel.Cloud)(((Cloud)Application.Current.BindingContext)); var isInternetConnected = (cloud.CurrentNetworkStatus != NetworkStatus.NotReachable) && await RestService.Instance.GetIsConnected(); if (!e.IsSignedIn) { if (isInternetConnected) { await Application.Current.MainPage.DisplayAlert((((e.ErrorType == SignInAErrorType.AccountCreationError) ? "Account Creation " : "Login ") + "Error"), e.SignedInError, "OK"); } else { await continueToNextPage(true, false); return; } } else { await continueToNextPage(true, true); } }
void BOSController_SignIn(object sender, SignInArgs e) { OnSignIn(e); }
public async Task <SignInApiResponse> SignInAsync(SignInArgs args) { return(await TryInvoceAsync(async() => { var response = new SignInApiResponse { Lang = Language }; if (args == null) { response.Error = "json parameters are empty"; return response; } if (string.IsNullOrWhiteSpace(args.Email)) { response.Error = BshkaraRes.Api_Auth_EmailIsEmpty; return response; } if (!args.Email.IsValidEmail()) { response.Error = BshkaraRes.Api_Auth_EmailIsNotValid; return response; } if (string.IsNullOrWhiteSpace(args.Password)) { response.Error = BshkaraRes.Api_Auth_PasswordIsEmpty; return response; } // Require the user to have a confirmed email before they can log on. var user = await UserManager.FindByNameAsync(args.Email); if (user == null) { response.Error = BshkaraRes.Api_Auth_UserNotExists; return response; } if (user != null) { if (!await UserManager.IsEmailConfirmedAsync(user.Id)) { response.Error = BshkaraRes.Api_Auth_EmailMustBeConfirmed; return response; } } var result = await SignInManager.PasswordSignInAsync(args.Email, args.Password, true, true); switch (result) { case SignInStatus.Success: response.SignInStatus = Bashkra.Shared.Enums.SignInStatus.Success; var climseIdenty = await user.GenerateUserIdentityAsync(UserManager); var ticket = new AuthenticationTicket(climseIdenty, new AuthenticationProperties()); var currentUtc = new SystemClock().UtcNow; ticket.Properties.IssuedUtc = currentUtc; ticket.Properties.ExpiresUtc = new DateTimeOffset(DateTime.UtcNow.AddDays(365)); ticket.Properties.IsPersistent = false; response.AccessToken = Startup.OAuthOptions.AccessTokenFormat.Protect(ticket); response.User = new ApiUser { Name = user.Name, Mobile = user.Mobile, Email = user.Email, Id = user.Id }; break; case SignInStatus.LockedOut: response.SignInStatus = Bashkra.Shared.Enums.SignInStatus.LockedOut; response.Error = BshkaraRes.Api_Auth_Lockout; break; case SignInStatus.RequiresVerification: response.SignInStatus = Bashkra.Shared.Enums.SignInStatus.RequiresVerification; response.Error = "RequiresVerification"; break; case SignInStatus.Failure: default: response.SignInStatus = Bashkra.Shared.Enums.SignInStatus.InvalidLoginOrPassword; response.Error = BshkaraRes.Api_Auth_InvalidLogin; break; } return response; })); }