Пример #1
0
        /// <summary>
        /// Marks the user as not first time login. This should be called after the user has gone to any page / or whatever process needs to run for first time users.
        /// </summary>
        public void MarkNonFirstTimeLogin()
        {
            this.firstTimeLogin = false;

            // Call a cmd proc to update this in the database.

            CommandProc commandProc = new CommandProc("CmdProcs.cmdMarkNonFirstTimeLogin", new string[] { "@UserID" }, new object[] { this.UserID });

            commandProc.CommandType = System.Data.CommandType.StoredProcedure;
            commandProc             = commandProc.Execute();

            //CommandProc mycommandProc = new CommandProc("[CmdProcs].[cmdSectionAccess]", ParameterArray, ValuesArray);
            //mycommandProc.Parameters.Add(new CommandProc.Parameter() { Name = "@HasAccess", Direction = System.Data.ParameterDirection.Output, SqlType = System.Data.SqlDbType.Bit });
            //mycommandProc.CommandType = System.Data.CommandType.StoredProcedure;
            //mycommandProc.FetchType = Singular.CommandProc.FetchTypes.DataRow;
            //mycommandProc = mycommandProc.Execute();

            //bPassCheck = Convert.ToBoolean(mycommandProc.Parameters[0].Value);
        }
Пример #2
0
        /// <summary>
        /// Adds rules to enforce Email Address entry and detect if a Username already exists
        /// </summary>
        protected override void AddCustomPasswordRule()
        {
            // Add custom password rule
            this.AddWebRule(EmailAddressProperty, u => u.EmailAddress == "", u => "Email address is required");

            JavascriptRule <User> rule = AddWebRule(User.LoginNameProperty, u => u.LoginName == "", u => "");

            rule.ASyncBusyText      = "Checking rule...";
            rule.ServerRuleFunction = (user) =>
            {
                CommandProc commandProc = new CommandProc("CmdProcs.cmdCheckUserExists", new string[] { "@UserID", "@UserName" }, new object[] { user.UserID, user.LoginName }, CommandProc.FetchTypes.DataRow);
                if (commandProc.Execute().DataRowValue != null)
                {
                    return("A user with this name already exists.");
                }
                else
                {
                    return("");
                }
            };
        }
Пример #3
0
        /// <summary>
        /// Reset a user's password
        /// </summary>
        /// <param name="userName">The user's username</param>
        public static void ResetPassword(string userName)
        {
            //string newPassword = Singular.Misc.Password.CreateRandomEasyPassword(8);
            string newPassword = "******";

            CommandProc commandProc = new CommandProc(
                "CmdProcs.cmdResetPassword",
                new string[] { "@UserName", "@RandomPassword" },
                new object[] { userName, OETLib.Security.OETWebSecurity.GetPasswordHash(newPassword) },
                Singular.CommandProc.FetchTypes.DataRow);

            commandProc = commandProc.Execute();

            if ((bool)commandProc.DataRow[0])
            {
                EMailBuilder.Create(commandProc.DataRow["EmailAddress"].ToString(), "Password Reset")
                .AddHeading("Password Reset")
                .AddParagraph("Please note, your password for OfficeExpressTuckShop has been reset to " + newPassword)
                .AddParagraph("Please log in as soon as possible, and change your password.")
                .AddRegards()
                .Save();
            }
        }