예제 #1
0
        private void UpdateEpiProfile(SiteUser user)
        {
            var profile = EPiServerProfile.Get(user.Username);

            profile["Email"] = user.Email;
            profile.Save();
        }
        public ActionResult Get()
        {
            var _username = User.Identity.Name;
            var profile   = EPiServerProfile.Get(_username);

            return(Rest(profile.Language));
        }
        /// <inheritdoc />
        public override ModuleViewModel CreateViewModel(ModuleTable moduleTable, IClientResourceService clientResourceService)
        {
            var options = ServiceLocator.Current.GetInstance <ExternalReviewOptions>();
            var model   = new AdvancedReviewsModuleViewModel(this, clientResourceService, options);
            var profile = EPiServerProfile.Get(PrincipalInfo.CurrentPrincipal.Identity.Name);

            model.Language = profile.Language;
            return(model);
        }
        protected internal virtual void CreateAdministratorIfNecessary()
        {
            if (!_firstRequest)
            {
                return;
            }

            _firstRequest = false;

            if (!this.Request.IsLocal)
            {
                return;
            }

            var userProvider = ServiceLocator.Current.GetInstance <UIUserProvider>();

            userProvider.GetAllUsers(0, 1, out var numberOfUsers);

            if (numberOfUsers > 0)
            {
                return;
            }

            var user = userProvider.CreateUser("Administrator", "P@ssword12", "*****@*****.**", null, null, true, out var status, out var errors);

            if (status == UIUserCreateStatus.Success)
            {
                const string administrationRoleName = "WebAdmins";
                var          roleProvider           = ServiceLocator.Current.GetInstance <UIRoleProvider>();
                roleProvider.CreateRole(administrationRoleName);
                roleProvider.AddUserToRoles(user.Username, new[] { administrationRoleName });

                if (ProfileManager.Enabled)
                {
                    var profile = EPiServerProfile.Get(user.Username);
                    profile.Email = user.Email;
                    profile.Save();
                }

                var contentSecurityRepository = ServiceLocator.Current.GetInstance <IContentSecurityRepository>();
                var contentSecurityDescriptor = contentSecurityRepository.Get(ContentReference.RootPage).CreateWritableClone() as IContentSecurityDescriptor;

                // ReSharper disable PossibleNullReferenceException
                contentSecurityDescriptor.AddEntry(new AccessControlEntry(administrationRoleName, AccessLevel.FullAccess));
                // ReSharper restore PossibleNullReferenceException
                contentSecurityRepository.Save(ContentReference.RootPage, contentSecurityDescriptor, SecuritySaveType.Replace);
            }
            else
            {
                // ReSharper disable PossibleMultipleEnumeration
                throw new InvalidOperationException("Could not create administrator.", errors.Any() ? new InvalidOperationException(errors.First()) : null);
                // ReSharper restore PossibleMultipleEnumeration
            }
        }
예제 #5
0
        /// <summary>
        /// Initialize ticket and user name
        /// </summary>
        private void Initialize()
        {
            var ticketParameter = Request[InvitationSender.TicketParameter];
            Ticket = string.IsNullOrEmpty(ticketParameter) ? null : InvitationTicket.Decrypt(ticketParameter);

            if ((Ticket != null) && !string.IsNullOrEmpty(Ticket.Email))
            {
                var enumerator = Membership.FindUsersByEmail(Ticket.Email).GetEnumerator();
                UserName = enumerator.MoveNext() ? ((MembershipUser)enumerator.Current).UserName : string.Empty;
            }

            Profile = string.IsNullOrEmpty(UserName) ? EPiServerProfile.Current : EPiServerProfile.Get(UserName);
        }
        protected void UpdateProfileImage(object sender, EventArgs e)
        {
            var userName = userPicker.SelectedValue;

            var selectedProfile = EPiServerProfile.Get(userName);
            var imageUrl        = GetFilePath();

            if (!string.IsNullOrEmpty(imageUrl))
            {
                selectedProfile.SetPropertyValue("ProfileImage", imageUrl);
                selectedProfile.Save();
            }
        }
예제 #7
0
 /// <summary>
 /// Creates new user
 /// <returns>If user was created</returns>
 /// </summary>
 private bool CreateUser()
 {
     try
     {
         Membership.CreateUser(TextBoxUserName.Text, TextBoxPassword.Text, Ticket.Email);
         UserName = TextBoxUserName.Text;
         Profile = EPiServerProfile.Get(UserName);
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }
        private void AddUser(string userName, string fullName, string passWord, string[] roleNames)
        {
            if (UIUserProvider.GetUser(userName) == null)
            {
                var email = string.Format("epic-{0}@mailinator.com", userName);
                IEnumerable <string> erros;
                UIUserCreateStatus   status;
                var user = UIUserProvider.CreateUser(userName, passWord, email, null, null, true, out status, out erros);
                UIRoleProvider.AddUserToRoles(user.Username, roleNames);

                var profile   = EPiServerProfile.Get(user.Username);
                var nameParts = fullName.Split(' ');
                profile["FirstName"] = nameParts[0];
                profile["LastName"]  = nameParts[1];
                // E-mail must be part of profile properties to be resolved by QueryableNotificationUsersImpl
                profile["Email"] = email;
                profile.Save();
            }
        }
        protected void RefreshImage(object sender, EventArgs e)
        {
            var userName    = userPicker.SelectedValue;
            var userProfile = EPiServerProfile.Get(userName);

            var imageUrl = userProfile.GetPropertyValue("ProfileImage").ToString();

            if (string.IsNullOrEmpty(imageUrl))
            {
                tbFilePath.Text             = string.Empty;
                profileImagePreview.Visible = false;
            }
            else
            {
                tbFilePath.Text = imageUrl;
                profileImagePreview.ImageUrl = imageUrl;
                profileImagePreview.Visible  = true;
            }
        }
예제 #10
0
        /// <summary>Execute subscription job</summary>
        protected virtual string InternalExecute()
        {
            int num1 = 0;
            int num2 = 0;

label_1:
            int totalRecords;
            ProfileInfoCollection allProfiles = ProfileManager.GetAllProfiles(ProfileAuthenticationOption.All, num2++, 1000, out totalRecords);

            if (allProfiles.Count == 0)
            {
                return(string.Format("{0} user profiles were found. {1} subscription e-mails were sent.", (object)totalRecords, (object)num1));
            }
            IEnumerator enumerator = allProfiles.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    EPiServerProfile profile = EPiServerProfile.Get(((ProfileInfo)enumerator.Current).UserName);
                    if (!SubscriptionJob.IsInInterval(profile.SubscriptionInfo.Interval, profile.SubscriptionInfo.LastMessage))
                    {
                        int num3 = this.SendSubscriptions(profile);
                        if (num3 >= 0)
                        {
                            profile.SubscriptionInfo.LastMessage = DateTime.Now;
                            num1 += num3;
                            profile.Save();
                        }
                    }
                }
                goto label_1;
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
        }