Exemple #1
0
        public ActionResult ResetPassword(string id)
        {
            BzureUser user = Actor.Public.AsUserManager().GetUserByID(id);

            if (user.IsNull())
            {
                return(RedirectToAction("UserList"));
            }
            ResetPasswordViewModel ViewModel = new ResetPasswordViewModel()
            {
                Title           = "重置密码",
                MasterViewModel = this.MasterViewModel,
                UserName        = user.UserName,
                Url             = Url.RouteUrl("SecurityApp_User", new { action = "ResetPassword" })
            };

            return(Result(ViewModel));
        }
Exemple #2
0
        public ActionResult AuthorizeUser(string id)
        {
            BzureUser user = Actor.Public.AsUserManager().GetUserByID(id);

            if (user.IsNull())
            {
                return(RedirectToAction("UserList"));
            }
            AuthorizeUserViewModel ViewModel = new AuthorizeUserViewModel()
            {
                MasterViewModel = this.MasterViewModel,
                Title           = "用户授权",
                Url             = Url.RouteUrl("SecurityApp_User", new { action = "AuthorizeUser" }),
                UserName        = user.UserName,
                UserState       = user.State > 0,
                Roles           = Actor.Public.AsRoleManager().GetAllTeamRoles(),
                RIDs            = Actor.Public.AsRoleManager().GetTeamRoleIDsByUserID(user.UserID.ToString())
            };

            return(Result(ViewModel));
        }
Exemple #3
0
        public ActionResult AuthorizeUser(string id, string UserState, FormCollection Collection)
        {
            BzureUser user = Actor.Public.AsUserManager().GetUserByID(id);

            if (user.IsNull())
            {
                return(RedirectToAction("UserList"));
            }
            //创建新的角色用户对应关系
            List <string> Roles = new List <string>();

            foreach (string key in Collection.AllKeys.Where(m => m.StartsWith("Role_")))
            {
                string roleid = Collection[key];
                if (roleid.IsNotNull())
                {
                    Roles.Add(roleid);
                }
            }
            user.State = UserState.IsNullOrEmpty() ? 0 : 1;
            NotificationViewModel notification = new NotificationViewModel();

            Actor.Public.AuthorizeUser(user, Roles.ToArray(), (bool ok) =>
            {
                if (ok)
                {
                    notification.Data             = NotificationData.YES;
                    notification.Content          = string.Format("用户:{0}授权保存成功", user.UserName);
                    notification.NotificationType = NotificationType.Success;
                }
                else
                {
                    notification.Data             = NotificationData.NO;
                    notification.Content          = string.Format("用户:{0}授权保存失败", user.UserName);
                    notification.NotificationType = NotificationType.Error;
                }
            });

            return(Result(notification));
        }
Exemple #4
0
        public ActionResult ResetPassword(string id, FormCollection Collection)
        {
            BzureUser user = Actor.Public.AsUserManager().GetUserByID(id);

            if (user.IsNull())
            {
                return(RedirectToAction("UserList"));
            }
            string password = Collection["NewPassword"];
            NotificationViewModel notification = new NotificationViewModel();

            notification.Data             = NotificationData.NO;
            notification.Content          = string.Format("用户:{0}密码重置失败", user.UserName);
            notification.NotificationType = NotificationType.Error;
            if (Actor.Public.AsAccountManager().SetPassword(user.UserName, Actor.Public.AsAccountManager().EncryptPassword(password)))
            {
                notification.Data             = NotificationData.YES;
                notification.Content          = string.Format("用户:{0}密码重置成功", user.UserName);
                notification.NotificationType = NotificationType.Success;
            }
            return(Result(notification));
        }
Exemple #5
0
        public ActionResult ResetNickName()
        {
            if (!Actor.Public.IsAuthenticated)
            {
                return(RedirectToAction("UserList"));
            }
            BzureUser user = Actor.Me.AsBzurePrincipal().ToUserModel().Entity;

            if (user.IsNull())
            {
                return(RedirectToAction("UserList"));
            }
            ResetNickNameViewModel ViewModel = new ResetNickNameViewModel()
            {
                Title           = "重置昵称",
                MasterViewModel = this.MasterViewModel,
                UserName        = user.UserName,
                NickName        = user.NickName,
                Url             = Url.RouteUrl("SecurityApp_User", new { action = "ResetNickName", id = user.UserID })
            };

            return(Result(ViewModel));
        }
Exemple #6
0
        public ActionResult ResetNickName(string id, FormCollection Collection)
        {
            BzureUser user = Actor.Public.AsUserManager().GetUserByID(id);

            if (user.IsNull())
            {
                return(RedirectToAction("UserList"));
            }
            string newNickName = Collection["NewNickName"];
            string msg         = string.Format("用户:{0}设置昵称:{1}失败", user.UserName, newNickName);

            if (Actor.Public.AsUserManager().ExistsNickName(newNickName))
            {
                msg = string.Format("用户:{0}设置昵称:{1}失败,因为昵称已经被占用", user.UserName, newNickName);
            }
            else
            {
                if (Actor.Public.AsUserManager().SetNickName(user.UserName, newNickName))
                {
                    msg = string.Format("用户:{0}昵称重置成功", user.UserName);
                }
                else
                {
                    msg = string.Format("用户:{0}设置昵称:{1}失败,可能是因为软件内部错误", user.UserName, newNickName);
                }
            }
            ResetNickNameViewModel ViewModel = new ResetNickNameViewModel()
            {
                Title           = "重置昵称",
                MasterViewModel = this.MasterViewModel,
                UserName        = user.UserName,
                Url             = Url.RouteUrl("SecurityApp_User", new { action = "ResetNickName", id = user.UserID }),
                Message         = msg
            };

            return(Result(ViewModel));
        }