/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e) { this.PageContext.QueryIDs = new QueryStringIDHelper("u", true); var dt = this.GetRepository <User>().ListAsDataTable(this.PageContext.PageBoardID, this.CurrentUserId, null); if (dt.Rows.Count != 1) { return; } var userRow = dt.GetFirstRow(); // do admin permission check... if (!this.PageContext.IsHostAdmin && this.IsUserHostAdmin(userRow)) { // user is not host admin and is attempted to edit host admin account... BuildLink.AccessDenied(); } if (this.IsPostBack) { return; } var userName = this.HtmlEncode(this.Get <BoardSettings>().EnableDisplayName ? userRow["DisplayName"].ToString() : userRow["Name"].ToString()); var header = string.Format(this.GetText("ADMIN_EDITUSER", "TITLE"), userName); this.Header.Text = this.IconHeader.Text = header; // current page label (no link) this.PageLinks.AddLink( header, string.Empty); this.Page.Header.Title = $"{this.GetText("ADMIN_ADMIN", "Administration")} - {this.GetText("ADMIN_USERS", "TITLE")} - {string.Format(this.GetText("ADMIN_EDITUSER", "TITLE"), userName)}"; // do a quick user membership sync... var user = this.Get <IAspNetUsersHelper>().GetMembershipUserById(this.CurrentUserId); // update if the user is not Guest if (!this.IsGuestUser) { AspNetRolesHelper.UpdateForumUser(user, this.PageContext.PageBoardID); } this.EditUserTabs.DataBind(); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e) { var user = this.GetRepository <User>().GetById(this.CurrentUserId); if (user == null) { return; } // do admin permission check... if (!this.PageContext.IsHostAdmin && user.UserFlags.IsHostAdmin) { // user is not host admin and is attempted to edit host admin account... BuildLink.AccessDenied(); } if (this.IsPostBack) { return; } var userName = this.HtmlEncode(this.Get <IUserDisplayName>().GetName(user)); var header = string.Format(this.GetText("ADMIN_EDITUSER", "TITLE"), userName); this.Header.Text = this.IconHeader.Text = header; // current page label (no link) this.PageLinks.AddLink( header, string.Empty); this.Page.Header.Title = $"{this.GetText("ADMIN_ADMIN", "Administration")} - {this.GetText("ADMIN_USERS", "TITLE")} - {string.Format(this.GetText("ADMIN_EDITUSER", "TITLE"), userName)}"; // do a quick user membership sync... var aspNetUser = this.Get <IAspNetUsersHelper>().GetMembershipUserById(this.CurrentUserId); // update if the user is not Guest if (!this.IsGuestUser) { AspNetRolesHelper.UpdateForumUser(aspNetUser, this.PageContext.PageBoardID); } this.EditUserTabs.DataBind(); }