Beispiel #1
0
        public void UpdateObject(User entity)
        {
            entity.UserName = UserName.Text.Trim();
            entity.Nick = Nick.Text.Trim();
            entity.Email = Email.Text.Trim();

            if (Password.Text.Length > 0)
            {
                entity.UpdatePassword(Password.Text);
            }

            var roleIds = new List<int>();

            foreach (ListItem item in RoleList.Items)
            {
                if (item.Selected)
                    roleIds.Add(Convert.ToInt32(item.Value));
            }

            var roles = NhSession.Query<Role>().Where(it => roleIds.Contains(it.Id));

            entity.Roles.Clear();

            foreach (var role in roles)
            {
                entity.Roles.Add(role);
            }
        }
Beispiel #2
0
        public static bool ValidateAccess(this IAdminControl control, User user)
        {
            Require.NotNull(control, "control");

            if (user == null)
            {
                return false;
            }

            string feature = control.Feature;

            if (!String.IsNullOrEmpty(feature) && !LicensingService.CurrentLicense.CmsEdition.IsFeatureAvailable(feature))
            {
                return false;
            }

            if (control.RequireSuperAdmin && user.IsSuperAdmin == false)
            {
                return false;
            }

            string pluginName = control.Plugin;
            string function = control.PermissionGroup;
            string operation = String.IsNullOrEmpty(control.Permission) ? "View" : control.Permission;

            if (!String.IsNullOrEmpty(function) && !user.HasPermission(pluginName, function, operation))
            {
                return false;
            }

            return true;
        }
Beispiel #3
0
        public void InitView(User entity)
        {
            RoleList.DataSource = NhSession.Query<Role>().OrderBy(it => it.Id);
            RoleList.DataBind();

            if (UserId > 0)
            {
                PasswordRequired.Enabled = false;
            }

            UserName.Text = entity.UserName;
            Nick.Text = entity.Nick;
            Email.Text = entity.Email;
            Password.Text = entity.Password;

            foreach (var role in entity.Roles)
            {
                foreach (ListItem item in RoleList.Items)
                {
                    if (Convert.ToInt32(item.Value) == role.Id)
                    {
                        item.Selected = true;
                    }
                }
            }
        }
Beispiel #4
0
 public static UserReference From(User user)
 {
     return new UserReference
     {
         Id = user.Id,
         UserName = user.UserName,
         Nick = user.Nick
     };
 }
 protected virtual bool Authorize(User user)
 {
     return true;
 }
Beispiel #6
0
 private bool Authorize(User user)
 {
     return user.HasPermission(null, "PageMgnt", "Design");
 }
Beispiel #7
0
 public AdminSession(User user)
 {
     User = user;
 }
Beispiel #8
0
 public override bool VerifyAccess(User user)
 {
     return user.HasPermission(null, "RoleMgnt", RoleId == 0 ? "Add" : "Edit");
 }
Beispiel #9
0
 public override bool VerifyAccess(User user)
 {
     return LicensingService.CurrentLicense.CmsEdition.IsFeatureAvailable(Features.Multilingual)
         && user.HasPermission(null, "SiteSetting", "FrontendLanguage");
 }
Beispiel #10
0
 public override bool VerifyAccess(User user)
 {
     return user.HasPermission(null, "FileMgnt", "UploadFile");
 }
Beispiel #11
0
 public virtual bool VerifyAccess(User user)
 {
     return true;
 }
Beispiel #12
0
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid) return;

            if (UserId > 0)
            {
                var user = NhSession.Get<User>(UserId);
                UpdateObject(user);
            }
            else
            {
                var user = new User();
                UpdateObject(user);
                NhSession.Save(user);
            }

            NhSession.Commit();

            Response.Redirect("UserList.aspx");
        }
Beispiel #13
0
 public override bool VerifyAccess(User user)
 {
     return user.IsSuperAdmin;
 }
Beispiel #14
0
 private static string GetAuthCookieName(User user)
 {
     return "[SEEGER]" + user.UserName;
 }
Beispiel #15
0
        public static void SetAuthCookie(User user, bool persistCredential)
        {
            Require.NotNull(user, "user");

            FormsAuthentication.SetAuthCookie(GetAuthCookieName(user), persistCredential);
        }
Beispiel #16
0
 public override bool VerifyAccess(User user)
 {
     return user.HasPermission(null, "UserMgnt", "View");
 }
 public override bool VerifyAccess(User user)
 {
     return user.HasPermission(null, "CustomRedirect", (RedirectId == 0) ? "Add" : "Edit");
 }
 public override bool VerifyAccess(User user)
 {
     return user.HasPermission(null, "SiteSetting", "FrontendSetting");
 }
Beispiel #19
0
 public override bool VerifyAccess(User user)
 {
     return true;
 }
Beispiel #20
0
 public override bool VerifyAccess(User user)
 {
     return user.HasPermission(null, "UserMgnt", (UserId == 0) ? "Add" : "Edit");
 }
 public override bool VerifyAccess(User user)
 {
     return user.HasPermission(null, "CustomRedirect", "View");
 }
Beispiel #22
0
 public override bool VerifyAccess(User user)
 {
     string operation = IsEditing ? "Edit" : "Add";
     return user.HasPermission(null, "PageMgnt", operation);
 }
Beispiel #23
0
 public override bool VerifyAccess(User user)
 {
     return user.HasPermission(null, "PageMgnt", "SEOSetting");
 }