Esempio n. 1
0
        public virtual void EditMemberProfile(Kooboo.CMS.Membership.Models.Membership membership, string userName, string email, string culture, string timeZoneId, string passwordQuestion = null,
                                              string passwordAnswer = null, Dictionary <string, string> profiles = null)
        {
            membership = membership.AsActual();

            MembershipUser membershipUser = new MembershipUser()
            {
                Membership = membership, UserName = userName
            }.AsActual();

            if (membershipUser == null)
            {
                throw new ArgumentException("The member doest not exists.");
            }
            if (!string.IsNullOrEmpty(email))
            {
                membershipUser.Email = email;
            }
            membershipUser.Culture          = culture;
            membershipUser.TimeZoneId       = timeZoneId;
            membershipUser.PasswordQuestion = passwordQuestion;
            membershipUser.PasswordAnswer   = passwordAnswer;
            membershipUser.Profiles         = profiles;

            _provider.Update(membershipUser, membershipUser);
        }
Esempio n. 2
0
        public virtual void Edit(Kooboo.CMS.Membership.Models.Membership membership, string userName, string email, bool isApproved, bool isLockedOut, string culture, string timeZoneId, string passwordQuestion = null,
                                 string passwordAnswer = null, string[] membershipGroups = null, Dictionary <string, string> profiles = null, string comment = null)
        {
            membership = membership.AsActual();

            MembershipUser membershipUser = new MembershipUser()
            {
                Membership = membership, UserName = userName
            }.AsActual();

            if (membershipUser == null)
            {
                throw new ArgumentException("The member doest not exists.");
            }
            membershipUser.Email            = email;
            membershipUser.Culture          = culture;
            membershipUser.TimeZoneId       = timeZoneId;
            membershipUser.PasswordQuestion = passwordQuestion;
            membershipUser.PasswordAnswer   = passwordAnswer;
            membershipUser.Comment          = comment;
            membershipUser.IsApproved       = isApproved;
            membershipUser.IsLockedOut      = isLockedOut;
            membershipUser.Profiles         = profiles;
            membershipUser.MembershipGroups = membershipGroups;

            _provider.Update(membershipUser, membershipUser);
        }
Esempio n. 3
0
        public virtual MembershipUser ForgotPassword(Kooboo.CMS.Membership.Models.Membership membership, string userName)
        {
            var membershipUser = new MembershipUser()
            {
                Membership = membership, UserName = userName
            }.AsActual();
            List <DataViolationItem> violations = new List <DataViolationItem>();

            if (membershipUser == null)
            {
                violations.Add(new DataViolationItem("UserName", userName, "The member does not exists."));
            }
            if (violations.Count > 0)
            {
                throw new DataViolationException(violations);
            }

            var activateCode = UniqueIdGenerator.GetInstance().GetBase32UniqueId(10);

            membershipUser.ActivateCode = activateCode;

            _provider.Update(membershipUser, membershipUser);

            return(membershipUser);
        }
Esempio n. 4
0
        public virtual MembershipUser CreateOrUpdateOAuthMember(Kooboo.CMS.Membership.Models.Membership membership, MembershipConnect membershipConnect, AuthResult authResult, Dictionary <string, string> profiles)
        {
            membership        = membership.AsActual();
            membershipConnect = membershipConnect.AsActual();

            var            userName       = _oauthMembershipProvider.GetUserName(authResult, membershipConnect);
            var            email          = _oauthMembershipProvider.GetEmail(authResult, membershipConnect);
            MembershipUser membershipUser = new MembershipUser()
            {
                Membership = membership, UserName = userName
            }.AsActual();
            Dictionary <string, string> extraData = null;

            if (authResult.ExtraData != null)
            {
                extraData = new Dictionary <string, string>(authResult.ExtraData);
            }
            if (membershipUser != null)
            {
                if (membershipUser.ProviderUserId == authResult.ProviderUserId)
                {
                    membershipUser.UtcLastLoginDate  = DateTime.UtcNow;
                    membershipUser.ProviderExtraData = extraData;
                    membershipUser.Profiles          = profiles;
                    if (profiles != null)
                    {
                        if (membershipUser.Profiles == null)
                        {
                            membershipUser.Profiles = new Dictionary <string, string>();
                        }
                        foreach (var item in profiles)
                        {
                            membershipUser.Profiles[item.Key] = item.Value;
                        }
                    }
                    membershipUser.MembershipGroups = membershipConnect.MembershipGroups;
                    _provider.Update(membershipUser, membershipUser);
                }
            }
            else
            {
                membershipUser = new MembershipUser()
                {
                    Membership = membership, UserName = userName
                };
                membershipUser.Email             = email;
                membershipUser.IsApproved        = true;
                membershipUser.UtcCreationDate   = DateTime.UtcNow;
                membershipUser.UtcLastLoginDate  = DateTime.UtcNow;
                membershipUser.Profiles          = profiles;
                membershipUser.MembershipGroups  = membershipConnect.MembershipGroups;
                membershipUser.ProviderType      = authResult.Provider;
                membershipUser.ProviderUserId    = authResult.ProviderUserId;
                membershipUser.ProviderExtraData = extraData;
                _provider.Add(membershipUser);
            }

            return(_provider.Get(membershipUser));
        }
Esempio n. 5
0
        private void CreateMembership(Site site, CreateSiteOptions options)
        {
            site = Get(site);

            var membershipName = site.Membership;

            //如果用户没有指定新的Membership名称,直接使用站点原来使用的名称。(有可能是导入的情况)
            if (!string.IsNullOrEmpty(options.MembershipName))
            {
                //如果有父站点,新的子站点的Membership名称使用 指定的名称+"_"+子站点的名称
                if (site.Parent != null)
                {
                    membershipName = options.MembershipName + "_" + site.Name;
                }
                else
                {
                    membershipName = options.MembershipName;
                }
            }
            site.Membership = membershipName;
            if (!string.IsNullOrEmpty(membershipName))
            {
                var membership = new Kooboo.CMS.Membership.Models.Membership(membershipName).AsActual();
                if (membership == null)
                {
                    var membershipFile = GetSiteRelatedFile(site, MembershipFileName);
                    if (!string.IsNullOrEmpty(membershipFile) && File.Exists(membershipFile))
                    {
                        using (FileStream fs = new FileStream(membershipFile, FileMode.Open, FileAccess.Read))
                        {
                            _membershipProvider.Import(membershipName, fs);
                        }
                        try
                        {
                            File.Delete(membershipFile);
                        }
                        catch (Exception e)
                        {
                            Kooboo.HealthMonitoring.Log.LogException(e);
                        }
                    }
                    else if (site.Parent != null && !string.IsNullOrEmpty(site.Membership))
                    {
                        site.Membership = Get(site.Parent).Membership;
                    }
                    else
                    {
                        site.Membership = null;
                    }
                }
            }
            Save(site);
            foreach (var childSite in ChildSites(site))
            {
                CreateMembership(childSite, options);
            }
        }
Esempio n. 6
0
        public virtual ActionResult Edit(string membershipName)
        {
            var membership = new Kooboo.CMS.Membership.Models.Membership()
            {
                Name = membershipName
            }.AsActual();

            return(View(membership));
        }
Esempio n. 7
0
        public static void RequestAuthentication(Kooboo.CMS.Membership.Models.Membership membership, string connectName, HttpContextBase httpContext, string returnUrl)
        {
            var client = GetAuthClient(membership, connectName);

            OpenAuthSecurityManager manager = new OpenAuthSecurityManager(httpContext, client.GetOpenAuthClient(), new MembershipOpenAuthDataProvider());

            manager.RequestAuthentication(returnUrl);
            //client.RequestAuthentication(httpContext, new Uri(returnUrl));
        }
Esempio n. 8
0
        public void Remove(Kooboo.CMS.Membership.Models.Membership item)
        {
            var entity = Get(item);

            if (entity != null)
            {
                _dbContext.Set <Kooboo.CMS.Membership.Models.Membership>().Remove(entity);
                _dbContext.SaveChanges();
            }
        }
Esempio n. 9
0
        public IQueryable <MembershipUser> All(Kooboo.CMS.Membership.Models.Membership membership, string filterName)
        {
            var all = _provider.All(membership);

            if (!string.IsNullOrEmpty(filterName))
            {
                all = all.Where(it => it.UserName.Contains(filterName));
            }
            return(all);
        }
Esempio n. 10
0
        public virtual ActionResult IsNameAvailable(string name)
        {
            var membership = new Kooboo.CMS.Membership.Models.Membership(name).AsActual();

            if (membership != null)
            {
                return(Json("The name is duplicate.".Localize(), JsonRequestBehavior.AllowGet));
            }
            return(Json(true, JsonRequestBehavior.AllowGet));
        }
        public virtual IEnumerable <MembershipConnect> All(Kooboo.CMS.Membership.Models.Membership membership, string filterName)
        {
            var list = _provider.All(membership);

            if (!string.IsNullOrEmpty(filterName))
            {
                list = list.Where(it => it.Name.Contains(filterName, StringComparison.OrdinalIgnoreCase));
            }
            return(list);
        }
        public IEnumerable <System.Web.Mvc.SelectListItem> GetSelectListItems(System.Web.Routing.RequestContext requestContext, string filter = null)
        {
            var membershipGroupManager = Kooboo.CMS.Common.Runtime.EngineContext.Current.Resolve <MembershipGroupManager>();
            var membership             = new Kooboo.CMS.Membership.Models.Membership(requestContext.GetRequestValue("membershipName"));

            return(membershipGroupManager.All(membership, "").Select(it => new SelectListItem()
            {
                Text = it.Name, Value = it.Name
            }));
        }
Esempio n. 13
0
        private void SetPassword(Kooboo.CMS.Membership.Models.Membership membership, MembershipUser membershipUser, string password)
        {
            var salt            = _passwordProvider.GenerateSalt();
            var encodedPassword = _passwordProvider.EncodePassword(membership, password, salt);

            if (encodedPassword == password)
            {
                salt = null;
            }
            membershipUser.Password     = encodedPassword;
            membershipUser.PasswordSalt = salt;
        }
Esempio n. 14
0
        public virtual MembershipUser Create(Kooboo.CMS.Membership.Models.Membership membership, string userName, string email, string password, bool isApproved, string culture, string timeZoneId, string passwordQuestion = null,
                                             string passwordAnswer = null, string[] membershipGroups = null, Dictionary <string, string> profiles = null, string comment = null)
        {
            membership = membership.AsActual();

            MembershipUser membershipUser = new MembershipUser()
            {
                Membership = membership
            };

            membershipUser.UserName = userName;
            List <DataViolationItem> violations = new List <DataViolationItem>();

            if (membershipUser.AsActual() != null)
            {
                violations.Add(new DataViolationItem("UserName", userName, "DuplicateUserName"));
            }
            if (_provider.QueryUserByEmail(membership, email) != null)
            {
                violations.Add(new DataViolationItem("Email", email, "DuplicateEmail"));
            }
            if (violations.Count > 0)
            {
                throw new DataViolationException(violations);
            }

            if (!string.IsNullOrEmpty(email))
            {
                membershipUser.Email = email;
            }
            membershipUser.Culture          = culture;
            membershipUser.TimeZoneId       = timeZoneId;
            membershipUser.PasswordQuestion = passwordQuestion;
            membershipUser.PasswordAnswer   = passwordAnswer;
            membershipUser.Comment          = comment;
            membershipUser.IsApproved       = isApproved;
            if (!membershipUser.IsApproved)
            {
                string activateCode = UniqueIdGenerator.GetInstance().GetBase32UniqueId(10);
                membershipUser.ActivateCode = activateCode;
            }
            membershipUser.UtcCreationDate  = DateTime.UtcNow;
            membershipUser.Profiles         = profiles;
            membershipUser.MembershipGroups = membershipGroups;

            SetPassword(membership, membershipUser, password);


            _provider.Add(membershipUser);

            return(_provider.Get(membershipUser));
        }
Esempio n. 15
0
        public virtual ActionResult Edit(Kooboo.CMS.Membership.Models.Membership model, string @return)
        {
            JsonResultData data = new JsonResultData(ModelState);

            if (ModelState.IsValid)
            {
                data.RunWithTry((resultData) =>
                {
                    _manager.Update(model, model);
                    resultData.RedirectUrl = @return;
                });
            }
            return(Json(data));
        }
Esempio n. 16
0
        protected virtual void Save(Kooboo.CMS.Membership.Models.Membership membership, List <T> list)
        {
            var file = GetDataFile(membership);

            GetLocker().EnterWriteLock();
            try
            {
                DataContractSerializationHelper.Serialize <List <T> >(list, file);
            }
            finally
            {
                GetLocker().ExitWriteLock();
            }
        }
Esempio n. 17
0
        public void Update(Kooboo.CMS.Membership.Models.Membership @new, Kooboo.CMS.Membership.Models.Membership old)
        {
            var entity = Get(@new);

            //Is there anyway to update the entity without reset the properties?
            entity.AuthCookieDomain                  = @new.AuthCookieDomain;
            entity.AuthCookieName                    = @new.AuthCookieName;
            entity.HashAlgorithmType                 = @new.HashAlgorithmType;
            entity.MaxInvalidPasswordAttempts        = @new.MaxInvalidPasswordAttempts;
            entity.MinRequiredPasswordLength         = @new.MinRequiredPasswordLength;
            entity.PasswordStrengthRegularExpression = @new.PasswordStrengthRegularExpression;

            _dbContext.SaveChanges();
        }
Esempio n. 18
0
        private void TransferData <T, TSource, TTarget>(Kooboo.CMS.Membership.Models.Membership membership)
            where T : IMemberElement, IIdentifiable
            where TSource : class, IMemberElementProvider <T>
            where TTarget : class, IMemberElementProvider <T>
        {
            var efProvider         = Kooboo.CMS.Common.Runtime.EngineContext.Current.Resolve <TSource>();
            var fileSystemProvider = Kooboo.CMS.Common.Runtime.EngineContext.Current.Resolve <TTarget>();

            foreach (var item in efProvider.All(membership))
            {
                item.Membership = membership;
                fileSystemProvider.Add(item);
            }
        }
Esempio n. 19
0
        public virtual string EncodePassword(Kooboo.CMS.Membership.Models.Membership membership, string pass, string salt)
        {
            HashAlgorithm hashAlgorithm = this.GetHashAlgorithm(membership.HashAlgorithmType);

            if (hashAlgorithm == null)
            {
                return(pass);
            }
            else
            {
                byte[] bytes   = Encoding.Unicode.GetBytes(pass);
                byte[] src     = Convert.FromBase64String(salt);
                byte[] inArray = null;
                if (hashAlgorithm is KeyedHashAlgorithm)
                {
                    KeyedHashAlgorithm algorithm2 = (KeyedHashAlgorithm)hashAlgorithm;
                    if (algorithm2.Key.Length == src.Length)
                    {
                        algorithm2.Key = src;
                    }
                    else if (algorithm2.Key.Length < src.Length)
                    {
                        byte[] dst = new byte[algorithm2.Key.Length];
                        Buffer.BlockCopy(src, 0, dst, 0, dst.Length);
                        algorithm2.Key = dst;
                    }
                    else
                    {
                        int    num2;
                        byte[] buffer5 = new byte[algorithm2.Key.Length];
                        for (int i = 0; i < buffer5.Length; i += num2)
                        {
                            num2 = Math.Min(src.Length, buffer5.Length - i);
                            Buffer.BlockCopy(src, 0, buffer5, i, num2);
                        }
                        algorithm2.Key = buffer5;
                    }
                    inArray = algorithm2.ComputeHash(bytes);
                }
                else
                {
                    byte[] buffer6 = new byte[src.Length + bytes.Length];
                    Buffer.BlockCopy(src, 0, buffer6, 0, src.Length);
                    Buffer.BlockCopy(bytes, 0, buffer6, src.Length, bytes.Length);
                    inArray = hashAlgorithm.ComputeHash(buffer6);
                }
                return(Convert.ToBase64String(inArray));
            }
        }
Esempio n. 20
0
        public ActionResult Create(Kooboo.CMS.Membership.Models.Membership membership, string @return)
        {
            JsonResultData data = new JsonResultData(ModelState);

            if (ModelState.IsValid)
            {
                data.RunWithTry((resultData) =>
                {
                    _manager.Add(membership);
                    resultData.RedirectUrl = @return;
                });
            }

            return(Json(data));
        }
Esempio n. 21
0
        public MembershipAuthentication(Site site, Kooboo.CMS.Membership.Models.Membership membership, HttpContextBase httpContextBase)
        {
            if (site == null)
            {
                throw new ArgumentNullException("site");
            }
            if (httpContextBase == null)
            {
                throw new ArgumentNullException("httpContextBase");
            }
            this._site       = site;
            this._membership = membership;

            this._httpContext = httpContextBase;
        }
Esempio n. 22
0
        public MembershipAuthentication(Site site, Kooboo.CMS.Membership.Models.Membership membership, HttpContextBase httpContextBase)
        {
            if (site == null)
            {
                throw new ArgumentNullException("site");
            }
            if (httpContextBase == null)
            {
                throw new ArgumentNullException("httpContextBase");
            }
            this._site = site;
            this._membership = membership;

            this._httpContext = httpContextBase;
        }
Esempio n. 23
0
        private Site CreateMembership(Site site, string membershipName)
        {
            //Create the repository if the repository does not exists.
            site = site.AsActual();

            if (!string.IsNullOrEmpty(membershipName))
            {
                var membership = new Kooboo.CMS.Membership.Models.Membership(membershipName).AsActual();
                if (membership == null)
                {
                    var membershipFile = GetSiteRelatedFile(site, MembershipFileName);
                    if (!string.IsNullOrEmpty(membershipFile) && File.Exists(membershipFile))
                    {
                        using (FileStream fs = new FileStream(membershipFile, FileMode.Open, FileAccess.Read))
                        {
                            _membershipProvider.Import(membershipName, fs);
                        }
                        site.Membership = membershipName;
                        try
                        {
                            File.Delete(membershipFile);
                        }
                        catch (Exception e)
                        {
                            Kooboo.HealthMonitoring.Log.LogException(e);
                        }
                    }
                    else if (site.Parent != null)
                    {
                        site.Membership = site.Parent.AsActual().Membership;
                    }
                    else
                    {
                        site.Membership = null;
                    }
                }
            }
            Save(site);
            foreach (var childSite in ChildSites(site))
            {
                CreateMembership(childSite, membershipName);
            }

            return(site);
        }
Esempio n. 24
0
        public virtual void ChangePassword(Kooboo.CMS.Membership.Models.Membership membership, string userName, string newPassword)
        {
            membership = membership.AsActual();
            MembershipUser membershipUser = new MembershipUser()
            {
                Membership = membership, UserName = userName
            }.AsActual();

            if (membershipUser == null)
            {
                throw new ArgumentException("The member doest not exists.");
            }

            SetPassword(membership, membershipUser, newPassword);
            membershipUser.UtcLastPasswordChangedDate = DateTime.UtcNow;

            _provider.Update(membershipUser, membershipUser);
        }
Esempio n. 25
0
        private static IAuthClient GetAuthClient(Kooboo.CMS.Membership.Models.Membership membership, string connectName)
        {
            var membershipConnect = new MembershipConnect()
            {
                Membership = membership, Name = connectName
            }.AsActual();

            if (membershipConnect == null)
            {
                throw new ArgumentException("Invalid membership connect.");
            }

            var authClient = Kooboo.CMS.Common.Runtime.EngineContext.Current.Resolve <IAuthClient>(membershipConnect.Name.ToLower());

            authClient.MembershipConnect = membershipConnect;

            return(authClient);
        }
Esempio n. 26
0
        public virtual bool Validate(Kooboo.CMS.Membership.Models.Membership membership, string userName, string password)
        {
            var membershipUser = new MembershipUser()
            {
                Membership = membership, UserName = userName
            }.AsActual();
            List <DataViolationItem> violations = new List <DataViolationItem>();

            if (membershipUser == null)
            {
                return(false);
            }
            if (!membershipUser.IsApproved)
            {
                violations.Add(new DataViolationItem("UserName", userName, "The member still not actived."));
            }
            if (membershipUser.IsLockedOut)
            {
                violations.Add(new DataViolationItem("UserName", userName, "The member was locked out."));
            }
            if (violations.Count > 0)
            {
                throw new DataViolationException(violations);
            }
            var encodedPassword = _passwordProvider.EncodePassword(membership, password, membershipUser.PasswordSalt);
            var valid           = encodedPassword == membershipUser.Password;

            if (valid == false && membership.MaxInvalidPasswordAttempts > 0)
            {
                membershipUser.InvalidPasswordAttempts++;
                if (membershipUser.InvalidPasswordAttempts >= membership.MaxInvalidPasswordAttempts)
                {
                    membershipUser.IsLockedOut        = true;
                    membershipUser.UtcLastLockoutDate = DateTime.UtcNow;
                }
            }
            else
            {
                membershipUser.UtcLastLoginDate = DateTime.UtcNow;
            }
            Update(membershipUser, membershipUser);
            return(valid);
        }
Esempio n. 27
0
        internal static AuthResult VerifyAuthenticationCore(Kooboo.CMS.Membership.Models.Membership membership, HttpContextBase context, string returnUrl)
        {
            IAuthClient client;
            string      providerName = OpenAuthSecurityManager.GetProviderName(context);

            if (string.IsNullOrEmpty(providerName))
            {
                return(AuthResult.Failed);
            }
            client = GetAuthClient(membership, providerName);
            if (client == null)
            {
                throw new InvalidOperationException("Invalid membership connect.");
            }
            OpenAuthSecurityManager manager = new OpenAuthSecurityManager(context, client.GetOpenAuthClient(), new MembershipOpenAuthDataProvider());
            var result = manager.VerifyAuthentication(returnUrl);

            return(new AuthResult(result));
        }
Esempio n. 28
0
        public MemberAuthentication(Site site, HttpContextBase httpContextBase)
        {
            if (site == null)
            {
                throw new ArgumentNullException("site");
            }
            if (httpContextBase == null)
            {
                throw new ArgumentNullException("httpContextBase");
            }
            this._site = site;
            this._membership = site.GetMembership();
            if (_membership == null)
            {
                throw new NullMembershipException();
            }

            this._httpContext = httpContextBase;
        }
Esempio n. 29
0
        public MemberAuthentication(Site site, HttpContextBase httpContextBase)
        {
            if (site == null)
            {
                throw new ArgumentNullException("site");
            }
            if (httpContextBase == null)
            {
                throw new ArgumentNullException("httpContextBase");
            }
            this._site       = site;
            this._membership = site.GetMembership();
            if (_membership == null)
            {
                throw new NullMembershipException();
            }

            this._httpContext = httpContextBase;
        }
Esempio n. 30
0
        public virtual bool ResetPassword(Kooboo.CMS.Membership.Models.Membership membership, string userName, string activateCode, string password)
        {
            var membershipUser = new MembershipUser()
            {
                Membership = membership, UserName = userName
            }.AsActual();

            List <DataViolationItem> violations = new List <DataViolationItem>();

            if (membershipUser == null)
            {
                violations.Add(new DataViolationItem("UserName", userName, "The member does not exists."));
            }
            if (string.IsNullOrEmpty(activateCode))
            {
                violations.Add(new DataViolationItem("ActivateCode", userName, "Activate code is null."));
            }

            var valid = !string.IsNullOrEmpty(membershipUser.ActivateCode) && membershipUser.ActivateCode == activateCode;

            if (valid)
            {
                SetPassword(membership, membershipUser, password);
                membershipUser.IsLockedOut = false;
                membershipUser.IsApproved  = true;
            }
            else
            {
                violations.Add(new DataViolationItem("ActivateCode", userName, "Activate code is invalid."));
            }
            if (violations.Count > 0)
            {
                throw new DataViolationException(violations);
            }


            membershipUser.ActivateCode = null;
            membershipUser.UtcLastPasswordChangedDate = DateTime.UtcNow;

            Update(membershipUser, membershipUser);

            return(valid);
        }
Esempio n. 31
0
        public virtual bool Activate(Kooboo.CMS.Membership.Models.Membership membership, string userName, string activateCode)
        {
            var membershipUser = new MembershipUser()
            {
                Membership = membership, UserName = userName
            }.AsActual();

            List <DataViolationItem> violations = new List <DataViolationItem>();

            if (membershipUser == null)
            {
                violations.Add(new DataViolationItem("UserName", userName, "The member does not exists."));
            }
            if (string.IsNullOrEmpty(activateCode))
            {
                violations.Add(new DataViolationItem("ActivateCode", userName, "Activate code is null."));
            }
            if (membershipUser.IsApproved)
            {
                return(true);
            }
            if (violations.Count > 0)
            {
                throw new DataViolationException(violations);
            }

            var isApproved = false;

            if (!string.IsNullOrEmpty(membershipUser.ActivateCode))
            {
                isApproved = membershipUser.ActivateCode == activateCode;
            }
            membershipUser.ActivateCode = null;
            if (isApproved == true)
            {
                membershipUser.IsApproved = true;
            }
            Update(membershipUser, membershipUser);
            return(isApproved);
        }
Esempio n. 32
0
        public virtual IEnumerable <T> All(Kooboo.CMS.Membership.Models.Membership membership)
        {
            var filePath = GetDataFile(membership);

            if (!File.Exists(filePath))
            {
                return(new T[0]);
            }
            GetLocker().EnterReadLock();
            try
            {
                var list = DataContractSerializationHelper.Deserialize <List <T> >(filePath) ?? new List <T>();
                foreach (var item in list)
                {
                    item.Membership = membership;
                }
                return(list);
            }
            finally
            {
                GetLocker().ExitReadLock();
            }
        }
Esempio n. 33
0
        public virtual ActionResult Edit(string membershipName)
        {
            var membership = new Kooboo.CMS.Membership.Models.Membership() { Name = membershipName }.AsActual();

            return View(membership);
        }
Esempio n. 34
0
 public virtual ActionResult IsNameAvailable(string name)
 {
     var membership = new Kooboo.CMS.Membership.Models.Membership(name).AsActual();
     if (membership != null)
     {
         return Json("The name is duplicate.".Localize(), JsonRequestBehavior.AllowGet);
     }
     return Json(true, JsonRequestBehavior.AllowGet);
 }
Esempio n. 35
0
 public IEnumerable<System.Web.Mvc.SelectListItem> GetSelectListItems(System.Web.Routing.RequestContext requestContext, string filter = null)
 {
     var membershipGroupManager = Kooboo.CMS.Common.Runtime.EngineContext.Current.Resolve<MembershipGroupManager>();
     var membership = new Kooboo.CMS.Membership.Models.Membership(requestContext.GetRequestValue("membershipName"));
     return membershipGroupManager.All(membership, "").Select(it => new SelectListItem() { Text = it.Name, Value = it.Name });
 }