public void ShippingEdits(object s, RepeaterCommandEventArgs e) { Address address = new Address(); Guid selectedAddress = new Guid(e.CommandArgument.ToString()); _user = new WebProfile().GetProfile(ddlCustomer.SelectedValue); address = _user.AddressCollection.Find(delegate(Address addressToFind) { return addressToFind.AddressId == selectedAddress && addressToFind.AddressType == AddressType.ShippingAddress; }); if (address.AddressId != Guid.Empty) { if (e.CommandName == "Edit") { //Do the edit pnlBillingAddresses.Visible = false; pnlShippingAddresses.Visible = false; pnlEditAddress.Visible = true; LoadEditPanel(address); tcMyAccount.ActiveTab = tpAddresses; } if (e.CommandName == "Delete") { _user.AddressCollection.Remove(address); _user.Save(); LoadAddresses(); tcMyAccount.ActiveTab = tpAddresses; } } }
/// <summary> /// Handles the Click event of the AddNewUser control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void AddNewUserClick(object sender, EventArgs e) { if (!Page.IsValid) { return; } var password = chkRandomPassword.Checked ? Membership.GeneratePassword(7, 0) : Password.Text; var createStatus = MembershipCreateStatus.Success; string resultMsg; var userIdText = UserName.Text; var emailText = Email.Text; var isActive = ActiveUser.Checked; var question = ""; var answer = ""; if (Membership.RequiresQuestionAndAnswer) { question = SecretQuestion.Text; answer = SecretAnswer.Text; } try { var mu = Membership.RequiresQuestionAndAnswer ? Membership.CreateUser(userIdText, password, emailText, question, answer, isActive, out createStatus) : Membership.CreateUser(userIdText, password, emailText); if (createStatus == MembershipCreateStatus.Success && mu != null) { var profile = new WebProfile().GetProfile(mu.UserName); profile.DisplayName = DisplayName.Text; profile.FirstName = FirstName.Text; profile.LastName = LastName.Text; profile.Save(); //auto assign user to roles var roles = RoleManager.GetAll(); foreach (var r in roles.Where(r => r.AutoAssign)) { RoleManager.AddUser(mu.UserName, r.Id); } } ResetForNewUser(); resultMsg = GetLocalResourceObject("UserCreated").ToString(); MessageContainer.IconType = BugNET.UserControls.Message.MessageType.Information; } catch (Exception ex) { resultMsg = GetLocalResourceObject("UserCreatedError") + "<br/>" + ex.Message; MessageContainer.IconType = BugNET.UserControls.Message.MessageType.Error; } MessageContainer.Text = resultMsg; MessageContainer.Visible = true; }
/// <summary> /// Binds a data source to the invoked server control and all its child controls. /// </summary> public override void DataBind() { if (MembershipData == null) return; var profile = new WebProfile().GetProfile(MembershipData.UserName); FirstName.Text = profile.FirstName; LastName.Text = profile.LastName; DisplayName.Text = profile.DisplayName; }
protected override void RunSample() { // ### Api Context // Pass in a `APIContext` object to authenticate // the call and to send a unique request id // (that ensures idempotency). The SDK generates // a request id if you do not pass one explicitly. // See [Configuration.cs](/Source/Configuration.html) to know more about APIContext. var apiContext = Configuration.GetAPIContext(); // Setup the profile we want to create var profile = new WebProfile() { name = Guid.NewGuid().ToString(), presentation = new Presentation() { brand_name = "Sample brand", locale_code = "US", logo_image = "https://www.paypal.com/" }, input_fields = new InputFields() { address_override = 1, allow_note = true, no_shipping = 0 }, flow_config = new FlowConfig() { bank_txn_pending_url = "https://www.paypal.com/", landing_page_type = "billing" } }; #region Track Workflow //-------------------- this.flow.AddNewRequest("Create profile", profile); //-------------------- #endregion // Create the profile var response = profile.Create(apiContext); #region Track Workflow //-------------------- this.flow.RecordResponse(response); //-------------------- #endregion #region Cleanup // Cleanup by deleting the newly-created profile var retrievedProfile = WebProfile.Get(apiContext, response.id); retrievedProfile.Delete(apiContext); #endregion }
private IActionResult ValidateCreateProfile(WebProfile webProfile, bool validBp) { if (!validBp) { return(new BadRequestObjectResult(new ServiceError { Code = (int)HttpStatusCode.BadRequest, Message = "The Customer Business Partner is Invalid" })); } //check validations for username, password, email, phonenumber //if any fails, respond with error codes. if (string.IsNullOrEmpty(webProfile?.CustomerCredentials?.Password)) { return(new BadRequestObjectResult(new ServiceError { Code = (int)HttpStatusCode.BadRequest, Message = "User name doesn't met with requirements." })); } //Check password for Uppercase, lower case , special character and number more than 8 characters //@"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\da-zA-Z]).{8,}$" if (Regex.Match(webProfile?.CustomerCredentials?.Password, @"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\da-zA-Z]).{8,}$").Length == 0) { return(new BadRequestObjectResult(new ServiceError { Code = (int)HttpStatusCode.BadRequest, Message = "Password provided doesn't met with Format requirements." })); } if (string.IsNullOrEmpty(webProfile?.CustomerCredentials?.UserName)) { return(new BadRequestObjectResult(new ServiceError { Code = (int)HttpStatusCode.BadRequest, Message = "Password doesn't met with requirements." })); } var result = ValidateEmailAddress(webProfile.Email); if (result != null) { return(result); } return(ValidatePhone(webProfile.Phone)); }
/// <summary> /// Calls the Signup Api in authentication repo to create users in Cognito as well as Cassandra /// </summary> /// <param name="profileInfo">contains information needed to sign the customer up</param> /// <returns></returns> public Task <IRestResponse <OkResult> > SignUpCustomer(WebProfile profileInfo) { var signUpInfo = new SignupRequest { BPId = profileInfo.BPId, Username = profileInfo.CustomerCredentials.UserName, Password = profileInfo.CustomerCredentials.Password, Email = profileInfo.Email }; return(SignUpCustomer(signUpInfo)); }
public JsonResult AuthenticateUser(string userName, string password, string deviceId) { try { var authenticated = Membership.ValidateUser(userName, password); if (authenticated) { var sessionGuid = Guid.NewGuid(); var session = new Session() { DeviceId = deviceId, SessionGuid = sessionGuid, UserName = userName, OpenedOn = DateTime.Now, IsValid = true, ClosedOn = DateTime.Now.AddYears(1) }; DbHelpers.AddSession(session); var response = new AuthenticationToken { IsAuthenticated = authenticated, Message = "Success", Role = Roles.GetRolesForUser(userName).Equals("Administrator") ? SmartVitals.Services.Enums.Roles.Administrator.ToString() : SmartVitals.Services.Enums.Roles.User.ToString(), Profile = UserInfo.GetFromProfile(WebProfile.GetProfile(userName, authenticated)), SessionId = authenticated ? sessionGuid : new Guid() }; return(Json( new JsonResponse <AuthenticationToken> { Response = response, Success = true }, JsonRequestBehavior.AllowGet )); } return(Json( new JsonResponse <AuthenticationToken> { Response = null, Success = false, Message = "Invalid username or password" }, JsonRequestBehavior.AllowGet )); } catch (Exception) { return(Json( new JsonResponse <AuthenticationToken> { Response = null, Success = false, Message = "An error occured while processing your request." }, JsonRequestBehavior.AllowGet )); } }
/// <summary> /// Create the default web experience profiles for this example website /// </summary> private void SeedWebProfiles(APIContext apiContext) { var digitalGoods = new WebProfile() { name = "DigitalGoods", input_fields = new InputFields() { no_shipping = 1 } }; WebProfile.Create(apiContext, digitalGoods); }
private void SeedWebProfile(APIContext apiContext) { var BigGods = new WebProfile() { name = "Ninja", input_fields = new InputFields() { no_shipping = 1 } }; WebProfile.Create(apiContext, BigGods); }
// GET: WebExperienceProfiles public ActionResult Index() { var apiContext = GetAPIContext(); var list = WebProfile.GetList(apiContext); if (!list.Any()) { SeedWebProfiles(apiContext); list = WebProfile.GetList(apiContext); } return(View(list)); }
/// <summary> /// Binds a data source to the invoked server control and all its child controls. /// </summary> public override void DataBind() { if (MembershipData == null) { return; } var profile = new WebProfile().GetProfile(MembershipData.UserName); FirstName.Text = profile.FirstName; LastName.Text = profile.LastName; DisplayName.Text = profile.DisplayName; }
public void WebProfileCreateTest() { var profile = WebProfileTest.GetWebProfile(); profile.name = Guid.NewGuid().ToString(); var response = profile.Create(TestingUtil.GetApiContext()); Assert.IsNotNull(response); Assert.IsNotNull(response.id); // Delete the profile profile = WebProfile.Get(TestingUtil.GetApiContext(), response.id); profile.Delete(TestingUtil.GetApiContext()); }
public ActionResult Index() { var apiContext = PayPalApiHelperService.GetApiContext(); var list = WebProfile.GetList(apiContext); if (!list.Any()) { SeedWebProfiles(apiContext); list = WebProfile.GetList(apiContext); } return(View(list)); }
/// <summary> /// Handles the Click event of the AddNewUser control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void AddNewUserClick(object sender, EventArgs e) { if (!Page.IsValid) { return; } var password = chkRandomPassword.Checked ? Membership.GeneratePassword(7, 0) : Password.Text; var createStatus = MembershipCreateStatus.Success; string resultMsg; var userIdText = UserName.Text; var emailText = Email.Text; var isActive = ActiveUser.Checked; try { var mu = Membership.CreateUser(userIdText, password, emailText); if (createStatus == MembershipCreateStatus.Success && mu != null) { var profile = new WebProfile().GetProfile(mu.UserName); profile.DisplayName = DisplayName.Text; profile.FirstName = FirstName.Text; profile.LastName = LastName.Text; profile.Save(); //auto assign user to roles var roles = RoleManager.GetAll(); foreach (var r in roles.Where(r => r.AutoAssign)) { RoleManager.AddUser(mu.UserName, r.Id); } } ResetForNewUser(); resultMsg = GetLocalResourceObject("UserCreated").ToString(); MessageContainer.IconType = BugNET.UserControls.Message.MessageType.Information; } catch (Exception ex) { resultMsg = GetLocalResourceObject("UserCreatedError") + "<br/>" + ex.Message; MessageContainer.IconType = BugNET.UserControls.Message.MessageType.Error; } MessageContainer.Text = resultMsg; MessageContainer.Visible = true; }
protected void Page_Load(object sender, EventArgs e) { // Get Profile start.................................................... if (!Page.IsPostBack) { if (Page.User.Identity.IsAuthenticated) { // get country names from app_code folder // bind country names to the dropdown list ddlCountries.DataSource = CountryNames.CountryNames.GetCountries(); ddlCountries.DataBind(); // get the selected user's profile based on query string WebProfile profile = Profile; // Subscriptions ddlNewsletter.SelectedValue = profile.Preferences.Newsletter; // Personal Info txtFirstName.Text = profile.Personal.FirstName; txtLastName.Text = profile.Personal.LastName; ddlGenders.SelectedValue = profile.Personal.Gender; if (profile.Personal.BirthDate != DateTime.MinValue) { txtBirthDate.Text = profile.Personal.BirthDate.ToShortDateString(); } ddlOccupations.SelectedValue = profile.Personal.Occupation; txtWebsite.Text = profile.Personal.Website; // Address Info ddlCountries.SelectedValue = profile.Address.Country; txtAddress.Text = profile.Address.Address; txtAptNumber.Text = profile.Address.AptNumber; txtCity.Text = profile.Address.City; txtState.Text = profile.Address.State; txtPostalCode.Text = profile.Address.PostalCode; // Contact Info txtDayTimePhone.Text = profile.Contacts.DayTimePhone; txtDayTimePhoneExt.Text = profile.Contacts.DayTimePhoneExt; txtEveningPhone.Text = profile.Contacts.EveningPhone; txtEveningPhoneExt.Text = profile.Contacts.EveningPhoneExt; txtCellPhone.Text = profile.Contacts.CellPhone; txtBusinessFax.Text = profile.Contacts.FaxBusiness; txtHomeFax.Text = profile.Contacts.FaxHome; } } // Get Profile end....................................................... }
public static void Save(UserInfo profile) { WebProfile p = WebProfile.GetProfile(profile.UserName); p.Age = profile.Age; p.Email = profile.Email; p.Height.Feet = profile.Height.Feet; p.Height.Inches = profile.Height.Inches; p.Name = profile.Name; p.Phone = profile.Phone; p.Sex = profile.Sex; p.Preferences = profile.Preferences; p.Weight = profile.Weight; p.Save(); }
/// <summary> /// Creates profile /// By signing up user in cognito and cassandra calling sign up API /// Save security questions by calling the security Questions API /// in eash step it will return approrate http status code /// </summary> /// <param name="webprofile"></param> /// <returns></returns> public async Task CreateWebProfileAsync(WebProfile webprofile) { _logger.LogInformation($"CreateWebProfileAsync({nameof(webprofile)}: {webprofile}"); //Signs up customer in cognito and cassandra var resp = await _authenticationApi.SignUpCustomer(webprofile); if (resp.StatusCode != HttpStatusCode.Created) { var message = resp.Content; _logger.LogError($"Unable to sign up for user name {webprofile?.CustomerCredentials?.UserName} and Bp {webprofile?.BPId} with error message from Auth sign up service {message}"); throw new Exception(message); } //save security questions await SaveSecurityQuestions(webprofile, resp); }
// GET: WebExperienceController public ActionResult Index() { //cria credencial api var apiContext = GetApiContext(); //cria experiance profile para colocar no payment object var list = WebProfile.GetList(apiContext); if (!list.Any()) { SeedWebProfile(apiContext); list = WebProfile.GetList(apiContext); } return(View(list)); }
protected void Page_Load(object sender, EventArgs e) { var CurrContext = HttpContext.Current; try { var apiContext = Configuration.GetAPIContext(); var profileList = WebProfile.GetList(apiContext); CurrContext.Items.Add("ResponseJson", Common.FormatJsonString(profileList.ConvertToJson())); } catch (Exception ex) { CurrContext.Items.Add("Error", ex.Message); } Server.Transfer("~/Response.aspx"); }
protected void Page_Load(object sender, EventArgs e) { var CurrContext = HttpContext.Current; var profile = new WebProfile(); var patchRequest = new PatchRequest(); try { var apiContext = Configuration.GetAPIContext(); // Setup the profile we want to create profile.name = Guid.NewGuid().ToString(); profile.presentation = new Presentation(); profile.presentation.brand_name = "Sample brand"; profile.presentation.locale_code = "US"; profile.presentation.logo_image = "https://www.paypal.com/"; profile.input_fields = new InputFields(); profile.input_fields.address_override = 1; profile.input_fields.allow_note = true; profile.input_fields.no_shipping = 0; profile.flow_config = new FlowConfig(); profile.flow_config.bank_txn_pending_url = "https://www.paypal.com/"; profile.flow_config.landing_page_type = "billing"; // Create the profile var response = profile.Create(apiContext); // Get the profile object and update the profile. var retrievedProfile = WebProfile.Get(apiContext, response.id); retrievedProfile.name = "A new name"; retrievedProfile.Update(apiContext); CurrContext.Items.Add("RequestJson", Common.FormatJsonString(retrievedProfile.ConvertToJson())); CurrContext.Items.Add("ResponseJson", "Experience profile successfully updated."); // Delete the newly-created profile retrievedProfile.Delete(apiContext); } catch (Exception ex) { CurrContext.Items.Add("Error", ex.Message); } Server.Transfer("~/Response.aspx"); }
public void SaveProfile() { // get the selected user's profile WebProfile profile = Profile; if (username.Length > 0) { profile = WebProfile.Get(username); } // Subscriptions profile.Preferences.Newsletter = ddlNewsletter.SelectedValue; // Personal Info profile.Personal.FirstName = txtFirstName.Text; profile.Personal.LastName = txtLastName.Text; profile.Personal.Gender = ddlGenders.SelectedValue; if (txtBirthDate.Text.Trim().Length > 0) { profile.Personal.BirthDate = DateTime.Parse(txtBirthDate.Text); } profile.Personal.Occupation = ddlOccupations.SelectedValue; profile.Personal.Website = txtWebsite.Text; // Address Info profile.Address.Country = ddlCountries.SelectedValue; profile.Address.Address = txtAddress.Text; profile.Address.AptNumber = txtAptNumber.Text; profile.Address.City = txtCity.Text; profile.Address.State = txtState.Text; profile.Address.PostalCode = txtPostalCode.Text; // Contact Info profile.Contacts.DayTimePhone = txtDayTimePhone.Text; profile.Contacts.DayTimePhoneExt = txtDayTimePhoneExt.Text; profile.Contacts.EveningPhone = txtEveningPhone.Text; profile.Contacts.EveningPhoneExt = txtEveningPhoneExt.Text; profile.Contacts.CellPhone = txtCellPhone.Text; profile.Contacts.FaxBusiness = txtBusinessFax.Text; profile.Contacts.FaxHome = txtHomeFax.Text; // this is what we will call from the button click // to save the user's profile profile.Save(); }
/// <summary> /// Handles the Click event of the Submit control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void Submit_Click(object sender, EventArgs e) { if (Page.IsValid) { // get the user by the reset token var token = Request.QueryString["token"]; if (!string.IsNullOrWhiteSpace(token)) { var user = UserManager.GetUserByPasswordResetToken(token); if (user != null) { try { // update the users password to the new password provided user.ChangePassword(user.ResetPassword(), Password.Text.Trim()); // update profile to clear the reset token and date var profile = new WebProfile().GetProfile(user.UserName); profile.PasswordVerificationToken = null; profile.PasswordVerificationTokenExpirationDate = null; profile.Save(); Response.Redirect("~/Account/PasswordResetSuccess.aspx"); } catch (System.Web.Security.MembershipPasswordException ex) { Message = ex.Message; message.Visible = !String.IsNullOrEmpty(Message); } } else { Message = GetLocalResourceObject("InvalidTokenMessage").ToString(); message.Visible = !String.IsNullOrEmpty(Message); } } else { Message = GetLocalResourceObject("InvalidTokenMessage").ToString(); message.Visible = !String.IsNullOrEmpty(Message); } } }
protected void ddlCustomer_SelectedIndexChanged(object sender, EventArgs e) { if (!string.IsNullOrEmpty(ddlCustomer.SelectedValue)) { _user = new WebProfile().GetProfile(ddlCustomer.SelectedValue); MembershipUser member = Membership.GetUser(_user.UserName); lblUserNameDisplay.Text = member.UserName; lblEmailDisplay.Text = member.Email; LoadOrders(); LoadAddresses(); LoadCountries(); tcMyAccount.Visible = true; } else { tcMyAccount.Visible = false; } }
public void WebProfileDeleteTest() { // Create a new profile var profileName = Guid.NewGuid().ToString(); var profile = WebProfileTest.GetWebProfile(); profile.name = profileName; var createdProfile = profile.Create(TestingUtil.GetApiContext()); // Get the profile object for the new profile profile = WebProfile.Get(TestingUtil.GetApiContext(), createdProfile.id); // Delete the profile profile.Delete(TestingUtil.GetApiContext()); // Attempt to get the profile. This should result in an exception. TestingUtil.AssertThrownException <PayPal.HttpException>(() => { WebProfile.Get(TestingUtil.GetApiContext(), profile.id); }); }
public SCWebProfile Convert(WebProfile webProfile) { if (webProfile == null) { return(null); } return(new SCWebProfile { Id = webProfile.Id, Kind = webProfile.Kind, Service = webProfile.Service, Title = webProfile.Title, Url = webProfile.Url, UserName = webProfile.UserName, CreatedAt = dateTimeConverter.SafeConvert(webProfile.CreatedAt) }); }
public void WebProfilePartialUpdateTest() { try { // Create a new profile var profileName = Guid.NewGuid().ToString(); var profile = WebProfileTest.GetWebProfile(); profile.name = profileName; var createdProfile = profile.Create(TestingUtil.GetApiContext()); // Get the profile object for the new profile profile = WebProfile.Get(TestingUtil.GetApiContext(), createdProfile.id); // Partially update the profile var newName = "New " + profileName; var patch1 = new Patch(); patch1.op = "add"; patch1.path = "/presentation/brand_name"; patch1.value = newName; var patch2 = new Patch(); patch2.op = "remove"; patch2.path = "/flow_config/landing_page_type"; var patchRequest = new PatchRequest(); patchRequest.Add(patch1); patchRequest.Add(patch2); profile.PartialUpdate(TestingUtil.GetApiContext(), patchRequest); // Get the profile again and verify it was successfully updated via the patch commands. var retrievedProfile = WebProfile.Get(TestingUtil.GetApiContext(), profile.id); Assert.AreEqual(newName, retrievedProfile.presentation.brand_name); Assert.IsTrue(string.IsNullOrEmpty(retrievedProfile.flow_config.landing_page_type)); // Delete the profile profile.Delete(TestingUtil.GetApiContext()); } catch (ConnectionException ex) { TestingUtil.WriteConnectionExceptionDetails(ex); throw; } }
public static async Task <string> CreateProfile() { SandboxEnvironment environment = new SandboxEnvironment( "AcsZudPzaw7QNmu68Q15SdtKMCM0HJMKO-q-Lp1IXgLwqe-Dt9CWOYqsBtZ_QiS2hVVL0o50BK8xW0Dk", "EJo0Vn_JKFf5qq4pN6zOKm50fmYN4dI8ZTeB5j2vl5YtWRnKeAPOvXK2WZ4faxGA8QaUM1KhVj-kF8kr"); _client = new PayPalHttpClient(environment); WebProfileCreateRequest request = new WebProfileCreateRequest(); WebProfile profile = new WebProfile { Name = "WebProfil", Presentation = new Presentation { BrandName = "eTeatar", LocaleCode = "US", LogoImage = "https://www.paypal.com/" }, InputFields = new InputFields { AddressOverride = 0, AllowNote = false, NoShipping = 1 }, FlowConfig = new FlowConfig { BankTxnPendingUrl = "https://www.paypal.com/", LandingPageType = "billing", UserAction = "commit", ReturnUriHttpMethod = "POST" }, Temporary = true }; request.RequestBody(profile); HttpResponse response = await _client.Execute(request); WebProfile result = response.Result <WebProfile>(); return(result.Id); }
public async Task DeleteWebProfile() { var expectedUri = new Uri("https://api.soundcloud.com/me/web-profiles/123?"); var gatewayMock = new Mock <ISoundCloudApiGateway>(MockBehavior.Strict); var statusResponse = new StatusResponse(); gatewayMock.Setup(x => x.SendDeleteRequestAsync <StatusResponse>(expectedUri)).ReturnsAsync(statusResponse); // Act var profile = new WebProfile { Id = 123 }; var result = await new Me(gatewayMock.Object).DeleteWebProfileAsync(profile); // Assert Assert.That(result, Is.SameAs(statusResponse)); }
//public IEnumerable<Test> Tests { get; set; } public static UserInfo GetFromProfile(WebProfile profile) { return(new UserInfo() { UserName = profile.UserName, Name = profile.Name, Sex = profile.Sex, Height = new Height { Feet = profile.Height.Feet, Inches = profile.Height.Inches }, Age = profile.Age, Weight = profile.Weight, Preferences = profile.Preferences , Phone = profile.Phone , Email = profile.Email }); }
protected void RegisterUser_CreatedUser(object sender, EventArgs e) { string continueUrl = RegisterUser.ContinueDestinationPageUrl; if (!OpenAuth.IsLocalUrl(continueUrl)) { continueUrl = "~/"; } var user = UserManager.GetUser(RegisterUser.UserName); var profile = new WebProfile().GetProfile(user.UserName); var displayName = (TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("DisplayName"); var firstName = (TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("FirstName"); var lastName = (TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("LastName"); profile.DisplayName = displayName.Text; profile.FirstName = firstName.Text; profile.LastName = lastName.Text; profile.Save(); // add users to all auto assigned roles var roles = RoleManager.GetAll(); foreach (var r in roles.Where(r => r.AutoAssign)) { RoleManager.AddUser(user.UserName, r.Id); } //send notification this user was created UserManager.SendUserRegisteredNotification(user.UserName); // send user verification email if enabled if (HostSettingManager.Get(HostSettingNames.UserRegistration, (int)UserRegistration.Verified) == (int)UserRegistration.Verified) { UserManager.SendUserVerificationNotification(user); } else { Response.Redirect(continueUrl); } }
public void WebProfileGetListTest() { // Create a new profile var apiContext = TestingUtil.GetApiContext(); var profileName = Guid.NewGuid().ToString(); var profile = WebProfileTest.GetWebProfile(); profile.name = profileName; var createdProfile = profile.Create(apiContext); // Get the list of profiles var profiles = WebProfile.GetList(apiContext); Assert.IsNotNull(profiles); Assert.IsTrue(profiles.Count > 0); // Delete the profile profile.id = createdProfile.id; profile.Delete(apiContext); }
protected override void RunSample() { // ### Api Context // Pass in a `APIContext` object to authenticate // the call and to send a unique request id // (that ensures idempotency). The SDK generates // a request id if you do not pass one explicitly. // See [Configuration.cs](/Source/Configuration.html) to know more about APIContext. var apiContext = Configuration.GetAPIContext(); #region Track Workflow this.flow.AddNewRequest("Retrieve list of profiles"); #endregion var profileList = WebProfile.GetList(apiContext); #region Track Workflow this.flow.RecordResponse(profileList); #endregion }
public JsonResult GetAuthenticationToken(string SessionGuid) { try { var selectedSession = DbHelpers.GetSessionByGuid(SessionGuid); if (selectedSession != null) { var response = new AuthenticationToken { IsAuthenticated = selectedSession.IsValid, Message = "Success", Role = Roles.GetRolesForUser(selectedSession.UserName).Equals("Administrator") ? SmartVitals.Services.Enums.Roles.Administrator.ToString() : SmartVitals.Services.Enums.Roles.User.ToString(), Profile = UserInfo.GetFromProfile(WebProfile.GetProfile(selectedSession.UserName, selectedSession.IsValid)), SessionId = selectedSession.IsValid ? new Guid(SessionGuid) : new Guid() }; return(Json( new JsonResponse <AuthenticationToken> { Response = response, Success = true }, JsonRequestBehavior.AllowGet )); } return(Json( new JsonResponse <AuthenticationToken> { Response = null, Success = true, Message = "Expired or invalid session." }, JsonRequestBehavior.AllowGet )); } catch (Exception) { return(Json( new JsonResponse <AuthenticationToken> { Response = null, Success = false, Message = "An error occured while processing your request." }, JsonRequestBehavior.AllowGet )); } }
protected void btnRegister_Click(object sender, EventArgs e) { string UserId = this.txtUserName.Text; MembershipUser user = Membership.CreateUser(UserId, UserId, txtEmail.Text); if (user != null) { FormsAuthentication.Authenticate(UserId, UserId); WebProfile Profile = new WebProfile(); Profile.Initialize(UserId, true); Profile.FirstName = this.txtFirstName.Text; Profile.LastName = this.txtLastName.Text; Profile.Newsletter = this.chkNewsLetter.Checked; Profile.Email = this.txtEmail.Text; Profile.Save(); GenericIdentity userIdentity = new GenericIdentity(UserId); GenericPrincipal userPrincipal = new GenericPrincipal(userIdentity, new string[] { "User" }); Context.User = userPrincipal; if (!Roles.IsUserInRole(User.Identity.Name, "User")) { PAB.Web.Providers.SimpleSqlRoleProvider prov = new SimpleSqlRoleProvider(); NameValueCollection config = new NameValueCollection(); config["connectionStringName"] = "OpenId"; System.Configuration.ConnectionStringSettings ConnectionStringSettings = System.Configuration.ConfigurationManager.ConnectionStrings[config["connectionStringName"]]; prov.Initialize("", config); prov.AddUsersToRoles(new string[] { User.Identity.Name }, new string[] { "User" }); } // go to a page for users who are authenticated Response.Redirect("Default2.aspx"); } else { //uh-oh! you handle it appropriately. } }
/// <summary> /// Handles the Click event of the cmdUpdate control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void CmdUpdateClick(object sender, EventArgs e) { try { GetMembershipData(UserId); if (MembershipData != null) { var profile = new WebProfile().GetProfile(MembershipData.UserName); profile.DisplayName = DisplayName.Text; profile.FirstName = FirstName.Text; profile.LastName = LastName.Text; ActionMessage.ShowSuccessMessage(GetLocalResourceObject("UpdateProfile").ToString()); OnAction(new ActionEventArgs { Trigger = ActionTriggers.Save }); } } catch { ActionMessage.ShowErrorMessage(LoggingManager.GetErrorMessageResource("ProfileUpdateError")); } }
/// <summary> /// Handles the Click event of the AddNewUser control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void AddNewUser_Click(object sender, EventArgs e) { string password; //if (chkRandomPassword.Checked) //{ // cvPassword.Enabled = false; // rvConfirmPassword.Enabled = false; // rvPassword.Enabled = false; // password = Membership.GeneratePassword(7, 0); //} //else //{ // rvConfirmPassword.Enabled = true; // rvPassword.Enabled = true; // password = Password.Text; //} if (!Page.IsValid) { return; } if (chkRandomPassword.Checked) { password = Membership.GeneratePassword(7, 0); } else { password = Password.Text; } MembershipCreateStatus createStatus = MembershipCreateStatus.Success; string resultMsg = ""; string userIDText = UserName.Text; string emailText = Email.Text; bool isActive = ActiveUser.Checked; string question = ""; string answer = ""; if (Membership.RequiresQuestionAndAnswer) { question = SecretQuestion.Text; answer = SecretAnswer.Text; } try { MembershipUser mu = null; if (Membership.RequiresQuestionAndAnswer) { mu = Membership.CreateUser(userIDText, password, emailText, question, answer, isActive, out createStatus); } else { mu = Membership.CreateUser(userIDText, password, emailText); } if (createStatus == MembershipCreateStatus.Success && mu != null) { WebProfile Profile = new WebProfile().GetProfile(mu.UserName); Profile.DisplayName = DisplayName.Text; Profile.FirstName = FirstName.Text; Profile.LastName = LastName.Text; Profile.Save(); //auto assign user to roles List<Role> roles = RoleManager.GetAll(); foreach (Role r in roles) { if (r.AutoAssign) RoleManager.AddUser(mu.UserName, r.Id); } } ImageButton2.Enabled = false; LinkButton2.Enabled = false; resultMsg = GetLocalResourceObject("UserCreated").ToString(); Message1.IconType = BugNET.UserControls.Message.MessageType.Information; } catch (Exception ex) { resultMsg = GetLocalResourceObject("UserCreatedError").ToString() + "<br/>" + ex.Message; Message1.IconType = BugNET.UserControls.Message.MessageType.Error; } Message1.Text = resultMsg; Message1.Visible = true; }
/// <summary> /// Handles the Click event of the AddNewUser control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void AddNewUserClick(object sender, EventArgs e) { if (!Page.IsValid) { return; } var password = chkRandomPassword.Checked ? Membership.GeneratePassword(7, 0) : Password.Text; var createStatus = MembershipCreateStatus.Success; string resultMsg; var userIdText = UserName.Text; var emailText = Email.Text; var isActive = ActiveUser.Checked; try { var mu = Membership.CreateUser(userIdText, password, emailText); if (createStatus == MembershipCreateStatus.Success && mu != null) { var profile = new WebProfile().GetProfile(mu.UserName); profile.DisplayName = DisplayName.Text; profile.FirstName = FirstName.Text; profile.LastName = LastName.Text; profile.Save(); //auto assign user to roles var roles = RoleManager.GetAll(); foreach (var r in roles.Where(r => r.AutoAssign)) { RoleManager.AddUser(mu.UserName, r.Id); } } if (!UserCustomFieldManager.SaveCustomFieldValues((Guid)mu.ProviderUserKey, ctlUserCustomFields.Values)) { throw new Exception(Resources.Exceptions.SaveCustomFieldValuesError); } ResetForNewUser(); resultMsg = GetLocalResourceObject("UserCreated").ToString(); MessageContainer.IconType = BugNET.UserControls.Message.MessageType.Information; } catch (Exception ex) { resultMsg = GetLocalResourceObject("UserCreatedError") + "<br/>" + ex.Message; MessageContainer.IconType = BugNET.UserControls.Message.MessageType.Error; } MessageContainer.Text = resultMsg; MessageContainer.Visible = true; }
/// <summary> /// Loads the ddlCustomers drop down list /// </summary> private void LoadCustomers() { _user = new WebProfile().GetProfile(ddlCustomer.SelectedValue); ddlCustomer.DataSource = Membership.GetAllUsers(); if (IsPostBack) { ddlCustomer.SelectedValue = _user.UserName; } ddlCustomer.DataBind(); ddlCustomer.Items.Insert(0, ""); }
protected void lbUpdateAddress_Click(object sender, EventArgs e) { _user = new WebProfile().GetProfile(ddlCustomer.SelectedValue); Address address = _user.AddressCollection.Find(delegate(Address addressToFind) { return addressToFind.AddressId == new Guid(hfAddressId.Value) && addressToFind.AddressType == (AddressType)Enum.Parse(typeof(AddressType), hfAddressType.Value); }); AddressType addressType = address.AddressType; _user.AddressCollection.Remove(address); _user.Save(); address.FirstName = txtFirstName.Text; address.LastName = txtLastName.Text; address.Phone = txtPhone.Text; address.Email = txtEmailEdit.Text; address.Address1 = txtAddress1.Text; address.Address2 = txtAddress2.Text; address.City = txtCity.Text; address.StateOrRegion = ddlStateOrRegion.SelectedValue; address.Country = ddlCountry.SelectedValue; address.PostalCode = txtPostalCode.Text; address.UserName = WebUtility.GetUserName(); address.AddressType = addressType; _user.AddressCollection.Add(address); _user.Save(); LoadAddresses(); pnlEditAddress.Visible = false; pnlBillingAddresses.Visible = true; pnlShippingAddresses.Visible = true; tcMyAccount.ActiveTab = tpAddresses; }