Exemple #1
0
    private void StoreUserInfo()
    {
        DL_WEB.DAL.Master.User oMasterUser = new DL_WEB.DAL.Master.User();

        if (0 != UserID)
        {
            oMasterUser.LoadByPrimaryKey(UserID);

            if (0 != oMasterUser.RowCount)
            {
                oMasterUser.IsInactive = cbIsInactive.Checked;
                oMasterUser.IsApproved = cbIsApproved.Checked;
                oMasterUser.Login      = tbLogin.Text;
                oMasterUser.Email      = tbLogin.Text;
            }
        }
        else
        {
            oMasterUser.AddNew();
            oMasterUser.IsInactive       = cbIsInactive.Checked;
            oMasterUser.IsApproved       = cbIsApproved.Checked;
            oMasterUser.Login            = tbLogin.Text;
            oMasterUser.Email            = tbLogin.Text;
            oMasterUser.GUID             = Guid.NewGuid();
            oMasterUser.Password         = oMasterUser.GUID.ToString();
            oMasterUser.PasswordQuestion = "?";
            oMasterUser.IsLockedOut      = false;
            oMasterUser.CreationDate     = DateTime.Now;
        }

        Session["MasterUser"] = oMasterUser;

        DL_WEB.DAL.Client.User oClientUser = FillClientUser(oMasterUser);

        Session.Add("ClientUser", oClientUser);
    }
Exemple #2
0
        public override MembershipUser CreateUser(string username,
                                                  string password,
                                                  string email,
                                                  string passwordQuestion,
                                                  string passwordAnswer,
                                                  bool isApproved,
                                                  object providerUserKey,
                                                  out MembershipCreateStatus status)
        {
            try
            {
                #region Checking if user with specified username exists

                DAL.Master.User oUser = new DL_WEB.DAL.Master.User();
                BusinessEntity.PushStaticConnectionString();

                //oUser.ConnectionString = ConfigurationManager.AppSettings[MyGeneration.dOOdads.BusinessEntity.DefaultConnectionStringConfig];
                oUser.Where.Login.Value = username;
                oUser.Query.Load();

                #endregion

                if (oUser.RowCount > 0)
                {
                    status = MembershipCreateStatus.DuplicateUserName;
                    return(null);
                }
                else
                {
                    oUser = new DL_WEB.DAL.Master.User();
                    oUser.AddNew();
                    oUser.Login            = email;
                    oUser.Password         = password;
                    oUser.Email            = email;
                    oUser.PasswordQuestion = null == passwordQuestion ? "?" : passwordQuestion;
                    oUser.PasswordAnswer   = null == passwordAnswer ? string.Empty : passwordAnswer;
                    oUser.IsApproved       = false;
                    oUser.IsLockedOut      = false;
                    oUser.GUID             = Guid.NewGuid();
                    oUser.CreationDate     = DateTime.Now;

                    oUser.Save();
                    status = MembershipCreateStatus.Success;
                    return(new MembershipUser(this.Name, oUser.Login, oUser.UserID, oUser.Email, oUser.PasswordQuestion, string.Empty, oUser.IsApproved, oUser.IsLockedOut, oUser.CreationDate, oUser.LastLoginDate, oUser.LastActivityDate, oUser.LastPasswordChangedDate, oUser.LastLockoutDate));
                }
            }
            catch (SqlException ex)
            {
                if (ex.Number == 2627) // unique key constraints
                {
                    status = MembershipCreateStatus.DuplicateEmail;
                }
                else
                {
                    status = MembershipCreateStatus.ProviderError;
                }
                return(null);
            }
            catch (Exception ex)
            {
                status = MembershipCreateStatus.ProviderError;
                return(null);
            }
            finally
            {
                BusinessEntity.PopStaticConnectionString();
            }
        }