private void SendToEmail(string subject) { var emailFrom = string.IsNullOrEmpty(MyReg.Read("EmailFrom")) ? string.Empty : MyReg.Read("EmailFrom"); using (SimpleLogin frm = new SimpleLogin(Application.ProductName, emailFrom)) { var result = frm.ShowDialog(); if (result == DialogResult.OK) { BaseEmail email = new BaseEmail(frm.Login, "smtp.gmail.com", "587", frm.Pwd); try { List <string> values = new List <string>(); foreach (object o in lbLog.Items) { values.Add(o.ToString()); } string selectedItems = String.Join("\n", values); email.SendMessage(subject, selectedItems, "*****@*****.**"); MyReg.Write("EmailFrom", frm.Login); } catch (Exception ex) { MessageBox.Show(ex.Message, "Sending email error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
public SalesforceSession Login() { lock (Lock) { SalesforceSession session; if (_config.UseSessionStore) { session = _sessionStore.RetrieveSession(_config.Environment ?? "Default"); if (session != null) { return(session); } } if (_config.Session != null) { return(_config.Session); } using (HttpClient httpClient = new HttpClient()) { XmlDocument response = httpClient.PerformRequest(SoapRequestManager.GetLoginRequest(_config)); SimpleLogin result = ResponseReader.ReadGenericResponse <SimpleLogin>(response, "result"); Uri instanceUrl = new Uri(result.ServerUrl); session = new SalesforceSession { Environment = _config.Environment, ApiVersion = _config.ApiVersion, IsSandbox = _config.IsSandbox, LastLogin = DateTime.Now, InstanceUrl = instanceUrl.Scheme + "://" + instanceUrl.Host, SessionId = result.SessionId, Proxy = _config.Proxy, BatchSize = _config.BatchSize, }; if (_config.UseSessionStore) { _sessionStore.StoreSession(session); } _config.Session = session; return(session); } } }
/// <summary> /// Login Action /// - Stores session data for re-use /// </summary> /// <returns></returns> public ZuoraSession Login() { lock (Lock) { ZuoraSession session; if (_config.UseSessionStore) { session = _sessionStore.RetrieveSession(_config.EnvironmentName ?? "Default"); if (session != null) { return(session); } } if (_config.Session != null) { return(_config.Session); } using (HttpClient httpClient = new HttpClient()) { XmlDocument response = httpClient.PerformRequest(SoapRequestManager.GetLoginRequest(_config)); SimpleLogin result = ResponseReader.ReadGenericResponse <SimpleLogin>(response); Uri instanceUrl = new Uri(result.ServerUrl); session = new ZuoraSession { SoapUrl = _config.SoapUrl, InstanceUrl = instanceUrl.Scheme + "://" + instanceUrl.Host, SessionId = result.SessionId }; if (_config.UseSessionStore) { _sessionStore.StoreSession(session); } _config.Session = session; _config.InstanceUrl = session.InstanceUrl; return(session); } } }
public object Login([FromBody] SimpleLogin currentLogin) { var currentUsername = currentLogin.UsernameDecoded(); var currentPassword = currentLogin.PasswordDecoded(); bool retVal = false; //todo: get an auth token and return to angular or whatever endpoint consuming medium, feel free to implement replacement at will bool login = AuthenticationManager.Login(currentUsername, currentPassword); if (login) { // sometimes used to persist user roles //string userData = string.Join("|", GetCustomUserRoles()); //Opted for forms auth, since this is how sitecore handles logging into shell FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( 1, // ticket version currentUsername, // authenticated username DateTime.Now, // issueDate DateTime.Now.AddMinutes(30), false, "", FormsAuthentication.FormsCookiePath); // the path for the cookie // Encrypt the ticket using the machine key string encryptedTicket = FormsAuthentication.Encrypt(ticket); // Add the cookie to the request to save it HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket); cookie.HttpOnly = true; HttpContext.Current.Response.Cookies.Add(cookie); // Your redirect logic retVal = true; } return(retVal); }
public LoginPage() { this.Title = "MobileFiT Coach"; _viewModel = new SimpleLogin (Manager.Instance.StaffMember, ExerciseService.ServiceAPI, Manager.Instance.ErrorLog); Image logoImage = new Image { Source = ImageSource.FromResource("WorkoutCreator.Images.mainpagelogo.png"), HorizontalOptions = LayoutOptions.FillAndExpand, Aspect = Aspect.AspectFill, HeightRequest = 167, WidthRequest = 225 }; AbsoluteLayout simpleLayout = new AbsoluteLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, }; // PositionProportional flag maps the range (0.0, 1.0) to // the range "flush [left|top]" to "flush [right|bottom]" AbsoluteLayout.SetLayoutFlags(logoImage, AbsoluteLayoutFlags.PositionProportional); Rectangle imageRectangle = new Rectangle(0.5, 0.5, logoImage.Height, logoImage.Width); AbsoluteLayout.SetLayoutBounds(logoImage, imageRectangle); simpleLayout.Children.Add(logoImage); Label pageTitle = new Label { Text = "Facility Login", FontSize = 40 }; Label usernameLabel = new Label { Text = "Username:"******"Enter Username", HeightRequest = 35 }; Label passwordLabel = new Label { Text = "Password:"******"Enter Password", IsPassword = true, HeightRequest = 35 }; Button loginButton = new Button { Text = "Login", }; ActivityIndicator activityIndicator = new ActivityIndicator { Color = Color.Red, IsRunning = false }; loginButton.Clicked += async (sender2, args2) => { activityIndicator.IsRunning = true; loginButton.IsEnabled = false; if (string.IsNullOrEmpty(usernameEntry.Text)) { activityIndicator.IsRunning = false; await this.DisplayAlert("Validation", "Input a username.", "OK"); } else { if (string.IsNullOrEmpty(passwordEntry.Text)) { activityIndicator.IsRunning = false; await this.DisplayAlert("Validation", "Input a password.", "OK"); } else { String loginResponse = await _viewModel.Login(usernameEntry.Text, passwordEntry.Text); if(!string.IsNullOrEmpty(loginResponse) || loginResponse == StringConstants._ConnectivityFailedValidationPrompt || loginResponse == StringConstants._AuthenticationFailedValidationPrompt ) { if(loginResponse == StringConstants._ConnectivityFailedValidationPrompt) { await this.DisplayAlert("Validation", StringConstants._ConnectivityFailedValidationPrompt, "OK"); }else { if(loginResponse == StringConstants._AuthenticationFailedValidationPrompt) { await this.DisplayAlert("Validation", StringConstants._AuthenticationFailedValidationPrompt, "OK"); } else { await this.DisplayAlert("Validation", "Unable to authenticate. Please try again.", "OK"); } } } else { usernameEntry.Text = ""; passwordEntry.Text = ""; Task task = _viewModel.SetLogginInUserContext(); Action<Task> action = (actionResult) => Device.BeginInvokeOnMainThread (async() => { Task<bool> taskResponder = null; if(App.WorkoutCreatorContext.StaffMember != null && App.WorkoutCreatorContext.StaffMember.GymID != 0) { taskResponder = App.RunBackroundSync(); } loginButton.IsEnabled = true; await Navigation.PushAsync(new PrimaryOptionsPage(taskResponder)); }); task.ContinueWith(action).ConfigureAwait(false); } activityIndicator.IsRunning = false; } } }; StackLayout nestedStack = new StackLayout { Children = { pageTitle, usernameLabel, usernameEntry, passwordLabel, passwordEntry, activityIndicator, loginButton }, Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.FillAndExpand, WidthRequest = 400, Padding = new Thickness(10), Spacing = 10 }; AbsoluteLayout.SetLayoutFlags(nestedStack, AbsoluteLayoutFlags.PositionProportional); AbsoluteLayout.SetLayoutBounds(nestedStack, new Rectangle(0.5, 0.5, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize)); StackLayout modalStack = new StackLayout { Children = { simpleLayout, nestedStack }, Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Padding = new Thickness(10) }; this.BackgroundColor = Color.FromRgb(135, 206, 250); this.Content = modalStack; }