Esempio n. 1
0
 public void AddApplication(string appAlias)
 {
     if (_lazyId.HasValue)
     {
         SetupUser(_lazyId.Value);
     }
     UserEntity.AddAllowedSection(appAlias);
 }
        public bool Execute(string packageName, XmlNode xmlData)
        {
            //Give access if no stores is created
            if (!StoreService.Instance.GetAll().Any())
            {
                IUser user = ApplicationContext.Current.Services.UserService.GetUserById(UmbracoContext.Current.Security.GetUserId());
                if (!user.AllowedSections.Contains("teacommerce"))
                {
                    user.AddAllowedSection("teacommerce");
                    ApplicationContext.Current.Services.UserService.Save(user);
                }

                //If your not the super admin - give access to the Tea Commerce default features
                Permissions permissions = PermissionService.Instance.GetCurrentLoggedInUserPermissions();
                if (permissions != null && !permissions.IsUserSuperAdmin)
                {
                    permissions.GeneralPermissions |= GeneralPermissionType.AccessSecurity;
                    permissions.GeneralPermissions |= GeneralPermissionType.AccessLicenses;
                    permissions.GeneralPermissions |= GeneralPermissionType.CreateAndDeleteStore;

                    permissions.Save();
                }
            }
            return(true);
        }
Esempio n. 3
0
        protected void ConfigureUserRights(IUser backofficeUser, IEnumerable <EasyADGroup> groupsUserIsIn)
        {
            var desiredSections = SectionResolver.Resolve(groupsUserIsIn);
            var newUserType     = UserTypeResolver.Resolve(groupsUserIsIn, AllUserTypes);

            var addSections    = desiredSections.Except(backofficeUser.AllowedSections).ToList();
            var removeSections = backofficeUser.AllowedSections.Except(desiredSections).ToList();

            if (newUserType.Id != backofficeUser.UserType.Id || addSections.Any() || removeSections.Any())
            {
                addSections.ForEach(s => backofficeUser.AddAllowedSection(s));
                removeSections.ForEach(s => backofficeUser.RemoveAllowedSection(s));
                backofficeUser.UserType = newUserType;
            }

            if (backofficeUser.IsDirty())
            {
                _userService.Save(backofficeUser);
            }
        }