예제 #1
0
        /// <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);

            DataTable dt = LegacyDb.user_list(this.PageContext.PageBoardID, this.CurrentUserID, null);

            if (dt.Rows.Count != 1)
            {
                return;
            }

            DataRow userRow = dt.Rows[0];

            // do admin permission check...
            if (!this.PageContext.IsHostAdmin && this.IsUserHostAdmin(userRow))
            {
                // user is not host admin and is attempted to edit host admin account...
                YafBuildLink.AccessDenied();
            }

            if (this.IsPostBack)
            {
                return;
            }

            this.PageLinks.AddRoot();
            this.PageLinks.AddLink(
                this.GetText("ADMIN_ADMIN", "Administration"), YafBuildLink.GetLink(ForumPages.admin_admin));

            this.PageLinks.AddLink(this.GetText("ADMIN_USERS", "TITLE"), YafBuildLink.GetLink(ForumPages.admin_users));

            var userName = this.Get <YafBoardSettings>().EnableDisplayName
                               ? userRow["DisplayName"].ToString()
                               : userRow["Name"].ToString();

            var header = this.GetText("ADMIN_EDITUSER", "TITLE").FormatWith(userName);

            this.Header.Text = this.Header2.Text = header;

            // current page label (no link)
            this.PageLinks.AddLink(
                header,
                string.Empty);

            this.Page.Header.Title = "{0} - {1} - {2}".FormatWith(
                this.GetText("ADMIN_ADMIN", "Administration"),
                this.GetText("ADMIN_USERS", "TITLE"),
                this.GetText("ADMIN_EDITUSER", "TITLE").FormatWith(userName));

            // do a quick user membership sync...
            MembershipUser user = UserMembershipHelper.GetMembershipUserById(this.CurrentUserID);

            // update if the user is not Guest
            if (!this.IsGuestUser)
            {
                RoleMembershipHelper.UpdateForumUser(user, this.PageContext.PageBoardID);
            }

            this.EditUserTabs.DataBind();
        }
예제 #2
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // we're in the admin section...
            ProfileEditControl.InAdminPages   = true;
            SignatureEditControl.InAdminPages = true;
            AvatarEditControl.InAdminPages    = true;

            PageContext.QueryIDs = new QueryStringIDHelper("u", true);

            DataTable dt = YAF.Classes.Data.DB.user_list(PageContext.PageBoardID, CurrentUserID, null);

            if (dt.Rows.Count == 1)
            {
                DataRow userRow = dt.Rows [0];

                // do admin permission check...
                if (!PageContext.IsHostAdmin && IsUserHostAdmin(userRow))
                {
                    // user is not host admin and is attempted to edit host admin account...
                    YafBuildLink.AccessDenied();
                }

                if (!IsPostBack)
                {
                    PageLinks.AddLink(PageContext.BoardSettings.Name, YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.forum));
                    PageLinks.AddLink("Administration", YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.admin_admin));
                    PageLinks.AddLink("Users", YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.admin_users));
                    PageLinks.AddLink(String.Format("Edit User \"{0}\"", userRow ["Name"].ToString()));

                    // do a quick user membership sync...
                    MembershipUser user = UserMembershipHelper.GetMembershipUser(CurrentUserID);
                    RoleMembershipHelper.UpdateForumUser(user, PageContext.PageBoardID);
                }
            }
        }
예제 #3
0
        /// <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.Rows[0];

            // 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.Header2.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 = UserMembershipHelper.GetMembershipUserById(this.CurrentUserId);

            // update if the user is not Guest
            if (!this.IsGuestUser)
            {
                RoleMembershipHelper.UpdateForumUser(user, this.PageContext.PageBoardID);
            }

            this.EditUserTabs.DataBind();
        }
예제 #4
0
        private void CommitEmailChange(string userId, string key)
        {
            object         provUserKey = (object)userId;
            MembershipUser user        = Membership.GetUser(provUserKey);

            string newEmail = GetNewEmail(user.ProviderUserKey);

            if (key == SharedWeb.Registration.GetValidationKey(newEmail, userId))
            {
                user.Email = newEmail;
                Membership.UpdateUser(user);
                int BoardID = Int32.Parse(ConfigurationSettings.AppSettings["YAF.BoardID"]);
                RoleMembershipHelper.UpdateForumUser(user, BoardID);
                DeleteFromChangeEmailTable(user.ProviderUserKey);
                Msg.Text = string.Format(Utils.GetText("CHANGEEMAIL", "EmailChanged"), newEmail);
            }
            else
            {
                Msg.Text = Utils.GetText("CHANGEEMAIL", "InvalidLink");
            }
        }
예제 #5
0
        protected void LoginRegister_Authenticate(object sender, AuthenticateEventArgs e)
        {
            TextBox UsernameTB        = (TextBox)this.LoginRegister.FindControl("UserName");
            TextBox PasswordTB        = (TextBox)this.LoginRegister.FindControl("Password");
            TextBox ConfirmPasswordTB = (TextBox)this.LoginRegister.FindControl("ConfirmPassword");
            TextBox EmailTB           = (TextBox)this.LoginRegister.FindControl("Email");

            string Username        = UsernameTB.Text.Trim();
            string Password        = PasswordTB.Text.Trim();
            string ConfirmPassword = ConfirmPasswordTB.Text.Trim();
            string Email           = EmailTB.Text.Trim();

            //tjek at begge passwords er ens (javascript?)

            if (Password != ConfirmPassword)
            {
                WarningMessage = Utils.GetText("REGISTRATION", "CreateProfilePasswordConfirmationFailed");
                return;
            }

            //opretter brugeren i asp.nets membership system
            MembershipUser NewUser = null;

            try
            {
                NewUser = Membership.CreateUser(Username, Password, Email);
            }
            catch (MembershipCreateUserException MemberShipException)
            {
                WarningMessage = Registration.GetErrorMessage(MemberShipException.StatusCode, Email);
                return;
            }

            if (NewUser != null)
            {
                //registrerer brugeren i yafs brugerliste
                int BoardID = Int32.Parse(ConfigurationSettings.AppSettings["YAF.BoardID"]);
                RoleMembershipHelper.UpdateForumUser(NewUser, BoardID);

                //giver brugeren rollen "unconfirmed"
                string UnconfirmedRole = ConfigurationSettings.AppSettings["SharedWeb.Registration.UnconfirmedRoleName"];
                Roles.AddUserToRole(Username, UnconfirmedRole);

                //Request.ServerVariables;


                //ip tjek
                string ThisIP          = Request.ServerVariables["REMOTE_ADDR"];
                int    MailsFromThisIP = (Application["MailsFrom_" + ThisIP] == null) ? 1 : (int)Application["MailsFrom_" + ThisIP];
                if (MailsFromThisIP > 3)
                {
                    WarningMessage = MailsFromThisIP.ToString() + "Fejl 2: Kunne ikke sende mail.";
                    return;
                }


                //Request.ServerVariables["REMOTE_ADDR"]

                //Sender bekræftelsesmail til bruger
                if (!Registration.SendConfirmMail(NewUser.UserName, NewUser.Email, NewUser.ProviderUserKey.ToString()))
                {
                    WarningMessage = "Fejl: Kunne ikke sende mai222l.";
                    return;
                }
                Application["MailsFrom_" + ThisIP] = MailsFromThisIP + 1;


                //Logger brugeren ind
                e.Authenticated = YafContext.Current.CurrentMembership.ValidateUser(Username, Password);

                // vzrus: to clear the cache to show user in the list at once
                YafContext.Current.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.UsersOnlineStatus));
            }
            else
            {
                WarningMessage = Utils.GetText("REGISTRATION", "CreateProfileErrorUnspecified");
            }
        }