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); } }
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; }
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; } } } }
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; }
private bool Authorize(User user) { return user.HasPermission(null, "PageMgnt", "Design"); }
public AdminSession(User user) { User = user; }
public override bool VerifyAccess(User user) { return user.HasPermission(null, "RoleMgnt", RoleId == 0 ? "Add" : "Edit"); }
public override bool VerifyAccess(User user) { return LicensingService.CurrentLicense.CmsEdition.IsFeatureAvailable(Features.Multilingual) && user.HasPermission(null, "SiteSetting", "FrontendLanguage"); }
public override bool VerifyAccess(User user) { return user.HasPermission(null, "FileMgnt", "UploadFile"); }
public virtual bool VerifyAccess(User user) { return true; }
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"); }
public override bool VerifyAccess(User user) { return user.IsSuperAdmin; }
private static string GetAuthCookieName(User user) { return "[SEEGER]" + user.UserName; }
public static void SetAuthCookie(User user, bool persistCredential) { Require.NotNull(user, "user"); FormsAuthentication.SetAuthCookie(GetAuthCookieName(user), persistCredential); }
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"); }
public override bool VerifyAccess(User user) { return true; }
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"); }
public override bool VerifyAccess(User user) { string operation = IsEditing ? "Edit" : "Add"; return user.HasPermission(null, "PageMgnt", operation); }
public override bool VerifyAccess(User user) { return user.HasPermission(null, "PageMgnt", "SEOSetting"); }