コード例 #1
0
        public ActionResult Details(string id)
        {
            UserGroup    ug    = _factory.CreateUserGroupDao().Get(id);
            IList <User> users = _factory.CreateUserDao().GetUsers(ug);

            return(View(new UserGroupDetailInfor(ug, users)));
        }
コード例 #2
0
        /// <summary>
        /// </summary>
        /// <param name="daoFactory"></param>
        /// <returns></returns>
        public bool Send(IMemberShipFactory daoFactory)
        {
            if (daoFactory == null)
            {
                throw new ArgumentNullException("daoFactory");
            }
            if (String.IsNullOrEmpty(Id))
            {
                throw new ArgumentException("Id", "Id is empty");
            }
            User myUsers = daoFactory.CreateUserDao().Get(Id);

            if (myUsers == null)
            {
                throw new ArgumentException("Id", String.Format("can not find any use with id={0}", Id));
            }
            EmailVerifier token = myUsers.Contact.VerifyEmail(30, daoFactory);

            var deleage = new CreateVariablesHandler(user => new Dictionary <string, string>
            {
                { "name", user.Name },
                { "parameters", token.CreateQueryString() }
            });

            OrnamentContext.Configuration.MessagesConfig.VerifyEmailAddress.Publish(daoFactory, deleage, myUsers);

            daoFactory.CreateUserDao().SaveOrUpdate(myUsers);
            return(true);
        }
コード例 #3
0
        public IEnumerable <object> Match([FromUri] UserSearch search)
        {
            if (OrnamentContext.MemberShip.HasRight("User", UserOperator.Read))
            {
                search = search ?? new UserSearch();
                int          total;
                IList <User> result = _factory.CreateUserDao()
                                      .Search(search, 0, 15, out total);

                return(from user in result
                       select new
                {
                    id = user.Id,
                    name = user.Name,
                    email = user.Contact.Email,
                    loginId = user.LoginId
                });
            }
            return(new object[]
            {
                new
                {
                    id = Resources.alertMsg_PermissionNotPermintAccessUsers,
                    name = Resources.alertMsg_PermissionNotPermintAccessUsers,
                    email = Resources.alertMsg_PermissionNotPermintAccessUsers,
                    loginId = Resources.alertMsg_PermissionNotPermintAccessUsers
                }
            });
        }
コード例 #4
0
 public JsonResult NotDuplicate(string loginId, string id)
 {
     if (loginId == null)
     {
         throw new ArgumentNullException("loginId");
     }
     loginId = Request.QueryString[0];
     return(Json(_memberShipFactory.CreateUserDao().Count(loginId, id) == 0, JsonRequestBehavior.AllowGet));
 }
コード例 #5
0
 public User Save(IMemberShipFactory memberShipFactory)
 {
     if (memberShipFactory == null) throw new ArgumentNullException("memberShipFactory");
     User user = memberShipFactory.CreateUserDao().Get(Id);
     UpdateOn(user);
     Permissions.UpdateOn(user);
     memberShipFactory.CreateUserDao().SaveOrUpdate(user);
     SessionManager.GetSessionWrapper().CurrentSession.SaveOrUpdate(user.Contact);
     if (VerifyEmail && EmailHasChanged)
     {
         SendVerifyEmail(user, memberShipFactory);
     }
     return user;
 }
コード例 #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id">Product's Id</param>
        /// <returns></returns>
        public ActionResult Create(int id)
        {
            var performers = new List <IPerformer>();

            performers.AddRange(_memberShipFactory.CreateUserDao().GetAll());
            performers.AddRange(_memberShipFactory.CreateUserGroupDao().GetAll());

            ViewData["performers"] = performers;

            var v = new ProjectModel
            {
                Product = _dao.ProductDao.Get(id)
            };

            return(View(v));
        }
コード例 #7
0
        public User Save(IMemberShipFactory memberShipFactory)
        {
            if (memberShipFactory == null)
            {
                throw new ArgumentNullException("memberShipFactory");
            }
            User user = memberShipFactory.CreateUserDao().Get(Id);

            UpdateOn(user);
            Permissions.UpdateOn(user);
            memberShipFactory.CreateUserDao().SaveOrUpdate(user);
            SessionManager.GetSessionWrapper().CurrentSession.SaveOrUpdate(user.Contact);
            if (VerifyEmail && EmailHasChanged)
            {
                SendVerifyEmail(user, memberShipFactory);
            }
            return(user);
        }
コード例 #8
0
        public ActionResult Details(string id)
        {
            IOrgDao      orgDao = _factory.CreateOrgDao();
            Org          org    = orgDao.Get(id);
            IList <User> users  = _factory.CreateUserDao().GetUsers(org);

            ViewData["ParentOrg"] = org.Parent;
            return(View(new OrgDetailsModel(org, users)));
        }
コード例 #9
0
        /// <summary>
        /// </summary>
        /// <param name="daoFactory"></param>
        public RetrievePasswordResult Retrieve(IMemberShipFactory daoFactory)
        {
            User user = daoFactory.CreateUserDao().GetByLoginId(AccountOrEmail) ??
                        daoFactory.CreateUserDao().GetUserByEmail(AccountOrEmail);
            if (user == null)
            {
                return RetrievePasswordResult.NotExistAccountOrEmail;
            }

            EmailVerifier emailToken = user.Security.ResetPassword(daoFactory, 50);
            var direct = new Dictionary<string, string>
            {
                {"name", user.Name},
                {"loginId", user.LoginId},
                {"parameters", emailToken.CreateQueryString()}
            };
            OrnamentContext.Configuration.MessagesConfig.RetrivePassword.Publish(daoFactory, direct, user);
            return RetrievePasswordResult.Success;
        }
コード例 #10
0
        /// <summary>
        /// </summary>
        /// <param name="daoFactory"></param>
        public RetrievePasswordResult Retrieve(IMemberShipFactory daoFactory)
        {
            User user = daoFactory.CreateUserDao().GetByLoginId(AccountOrEmail) ??
                        daoFactory.CreateUserDao().GetUserByEmail(AccountOrEmail);

            if (user == null)
            {
                return(RetrievePasswordResult.NotExistAccountOrEmail);
            }

            EmailVerifier emailToken = user.Security.ResetPassword(daoFactory, 50);
            var           direct     = new Dictionary <string, string>
            {
                { "name", user.Name },
                { "loginId", user.LoginId },
                { "parameters", emailToken.CreateQueryString() }
            };

            OrnamentContext.Configuration.MessagesConfig.RetrivePassword.Publish(daoFactory, direct, user);
            return(RetrievePasswordResult.Success);
        }
コード例 #11
0
        /// <summary>
        /// </summary>
        /// <param name="token"></param>
        /// <param name="daoFactory"></param>
        /// <returns></returns>
        /// <exception cref="EmailSecurityTimeoutException">User Token is Timeout</exception>
        public virtual VerifyResult Verify(string token, IMemberShipFactory daoFactory)
        {
            VerifyResult re = Verify(token);

            if (re == VerifyResult.Success)
            {
                this.Account.Contact.EmailVerified = true;
                daoFactory.CreateUserDao().SaveOrUpdate(this.Account);
            }
            daoFactory.CreateEmailVerifierDao().SaveOrUpdate(this);

            return(re);
        }
コード例 #12
0
        /// <summary>
        /// </summary>
        /// <param name="daoFactory"></param>
        /// <returns></returns>
        public bool Send(IMemberShipFactory daoFactory)
        {
            if (daoFactory == null) throw new ArgumentNullException("daoFactory");
            if (String.IsNullOrEmpty(Id))
                throw new ArgumentException("Id", "Id is empty");
            User myUsers = daoFactory.CreateUserDao().Get(Id);
            if (myUsers == null)
            {
                throw new ArgumentException("Id", String.Format("can not find any use with id={0}", Id));
            }
            EmailVerifier token = myUsers.Contact.VerifyEmail(30, daoFactory);

            var deleage = new CreateVariablesHandler(user => new Dictionary<string, string>
            {
                {"name", user.Name},
                {"parameters", token.CreateQueryString()}
            });
            OrnamentContext.Configuration.MessagesConfig.VerifyEmailAddress.Publish(daoFactory, deleage, myUsers);

            daoFactory.CreateUserDao().SaveOrUpdate(myUsers);
            return true;
        }
コード例 #13
0
        public object Execute(IMemberShipFactory factory)
        {
            IUserDao dao = factory.CreateUserDao();

            for (int i = 0; i < Ids.Length; i++)
            {
                string id = Ids[i];
                User user = dao.Load(id);
                user.IsDeny = IsDeny;
                dao.SaveOrUpdate(user);
            }

            return new {success = true};
        }
コード例 #14
0
        public object Execute(IMemberShipFactory factory)
        {
            IUserDao dao = factory.CreateUserDao();

            for (int i = 0; i < Ids.Length; i++)
            {
                string id   = Ids[i];
                User   user = dao.Load(id);
                user.IsDeny = IsDeny;
                dao.SaveOrUpdate(user);
            }

            return(new { success = true });
        }
コード例 #15
0
        public VerifyResult Save(IMemberShipFactory factory)
        {
            EmailVerifier userToken = factory.CreateEmailVerifierDao().Get(Id);

            if (userToken == null)
            {
                return VerifyResult.NotFoundTokenId;
            }
            if (userToken.Verify(TokenId, factory) == VerifyResult.Success)
            {
                userToken.Account.Security.ChangePassword(PasswordModel.NewPassword);
                factory.CreateUserDao().Update(userToken.Account);
                return VerifyResult.Success;
            }
            return VerifyResult.Failed;
        }
コード例 #16
0
        public VerifyResult Save(IMemberShipFactory factory)
        {
            EmailVerifier userToken = factory.CreateEmailVerifierDao().Get(Id);

            if (userToken == null)
            {
                return(VerifyResult.NotFoundTokenId);
            }
            if (userToken.Verify(TokenId, factory) == VerifyResult.Success)
            {
                userToken.Account.Security.ChangePassword(PasswordModel.NewPassword);
                factory.CreateUserDao().Update(userToken.Account);
                return(VerifyResult.Success);
            }
            return(VerifyResult.Failed);
        }
コード例 #17
0
        // PUT api/friends/5
        public void Put(string userId, [FromBody] string @group)
        {
            FriendGroup friendGroup = _dao.CreateFriendGroupDao().GetByName(@group);
            User        user        = _dao.CreateUserDao().Get(userId);

            if (friendGroup == null)
            {
                friendGroup = new FriendGroup
                {
                    Name = @group
                }
            }
            ;

            friendGroup.Friends.Add(new Friend(user));
        }
コード例 #18
0
        /// <summary>
        /// </summary>
        /// <param name="loginUser"></param>
        /// <param name="token"></param>
        /// <param name="daoFactory"></param>
        /// <returns></returns>
        public VerifyResult Verify(User loginUser, string token, IMemberShipFactory daoFactory)
        {
            if (loginUser != _emailVerifier.Account)
            {
                return(VerifyResult.Failed);
            }

            if (_emailVerifier.Type == VerifyType.Email &&
                _emailVerifier.Verify(token, daoFactory) == VerifyResult.Success)
            {
                daoFactory.CreateUserDao().SaveOrUpdate(loginUser);
                return(VerifyResult.Success);
            }

            return(VerifyResult.Failed);
        }
コード例 #19
0
        public object Execute(IMemberShipFactory factory)
        {
            IUserDao dao = factory.CreateUserDao();

            for (int i = 0; i < Ids.Length; i++)
            {
                string id = Ids[i];
                User user = dao.Get(id);
                if (!Lockout)
                {
                    user.Security.Unlock();
                }
                else
                {
                    user.Security.Lockout();
                }
            }

            return new {success = true};
        }
コード例 #20
0
        public object Execute(IMemberShipFactory factory)
        {
            IUserDao dao = factory.CreateUserDao();

            for (int i = 0; i < Ids.Length; i++)
            {
                string id   = Ids[i];
                User   user = dao.Get(id);
                if (!Lockout)
                {
                    user.Security.Unlock();
                }
                else
                {
                    user.Security.Lockout();
                }
            }

            return(new { success = true });
        }
コード例 #21
0
        /// <summary>
        ///     Create a user and send a active email to user.
        /// </summary>
        public bool Create(IMemberShipFactory dao, out string errorMessage)
        {
            errorMessage = null;
            var createUser = new User(LoginId, Password);
            UpdateOn(createUser);
            //Check duplicate account.
            IUserDao userDao = dao.CreateUserDao();
            User user = userDao.GetByLoginId(createUser.LoginId);
            if (user != null)
            {
                errorMessage = "Duplciate login Id.";
                return false;
            }
            userDao.SaveOrUpdate(createUser);
            userDao.Flush();
            if (this.VerifyEmail)
            {
                SendVerifyEmail(createUser, dao);
            }

            return true;
        }
コード例 #22
0
        /// <summary>
        ///     Create a user and send a active email to user.
        /// </summary>
        public bool Create(IMemberShipFactory dao, out string errorMessage)
        {
            errorMessage = null;
            var createUser = new User(LoginId, Password);

            UpdateOn(createUser);
            //Check duplicate account.
            IUserDao userDao = dao.CreateUserDao();
            User     user    = userDao.GetByLoginId(createUser.LoginId);

            if (user != null)
            {
                errorMessage = "Duplciate login Id.";
                return(false);
            }
            userDao.SaveOrUpdate(createUser);
            userDao.Flush();
            if (this.VerifyEmail)
            {
                SendVerifyEmail(createUser, dao);
            }

            return(true);
        }
コード例 #23
0
 public UserController(IMemberShipFactory memberShipFactory)
 {
     _memberShipFactory = memberShipFactory;
     _userDao = _memberShipFactory.CreateUserDao();
 }
コード例 #24
0
 protected override IList <User> GetInsideUsers(IMemberShipFactory memberShipFactory)
 {
     return(memberShipFactory.CreateUserDao().GetUsersInRole(Name));
 }
コード例 #25
0
 public bool ChangePassword([FromBody] ChangePasswordModel password)
 {
     return(password.ChangePassword(OrnamentContext.MemberShip.CurrentUser(), _memberShipFactory.CreateUserDao()));
 }
コード例 #26
0
 public UserController(IMemberShipFactory memberShipFactory)
 {
     _memberShipFactory = memberShipFactory;
     _userDao           = _memberShipFactory.CreateUserDao();
 }
コード例 #27
0
        /// <summary>
        /// </summary>
        /// <param name="loginUser"></param>
        /// <param name="token"></param>
        /// <param name="daoFactory"></param>
        /// <returns></returns>
        public VerifyResult Verify(User loginUser, string token, IMemberShipFactory daoFactory)
        {
            if (loginUser != _emailVerifier.Account)
            {
                return VerifyResult.Failed;
            }

            if (_emailVerifier.Type == VerifyType.Email
                && _emailVerifier.Verify(token, daoFactory) == VerifyResult.Success)
            {
                daoFactory.CreateUserDao().SaveOrUpdate(loginUser);
                return VerifyResult.Success;
            }

            return VerifyResult.Failed;
        }
コード例 #28
0
 protected override IList <User> GetInsideUsers(IMemberShipFactory memberShipFactory)
 {
     return(memberShipFactory.CreateUserDao().GetUsers(this.UserGroup));
 }