示例#1
0
        /// <summary>
        ///     Handles the Click event of the _btnLogin 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 _btnLogin_Click(object sender, EventArgs e)
        {
            if (_txtEmail.Text.Trim() == String.Empty || _txtPassword.Text.Trim() == String.Empty)
            {
                WriteFeedBackMaster(FeedbackType.Warning, "Please enter a username and password.");
            }


            if (!UserUtilities.Login(_txtEmail.Text.Trim(), _txtPassword.Text.Trim()))
            {
                return;
            }

            FormsAuthentication.SignOut();
            Session.RemoveAll();
            //add Session stuff here!!
            var userObj = new CurrentUserObj(_txtEmail.Text.Trim());

            Session["currentUser"] = userObj;
            Session.Timeout        = 60;
            FormsAuthentication.SetAuthCookie(_txtEmail.Text.Trim(), true);

            SetLoginControls();

            RadAjaxManager.GetCurrent(Page).Redirect("~/App/Pages/MyAccount.aspx");
        }
        private void SetCurrentUser_MasterMonthlyOperation()
        {
            CurrentUserObj currentUserObj = new CurrentUserObj();

            currentUserObj.UserID        = BUser.CurrentUser.ID.ToString();
            currentUserObj.UserName      = BUser.CurrentUser.UserName;
            currentUserObj.PersonnelID   = BUser.CurrentUser.Person.ID.ToString();
            currentUserObj.PersonnelName = BUser.CurrentUser.Person.Name;

            this.hfCurrentUser_MasterMonthlyOperation.Value = this.JsSerializer.Serialize(currentUserObj);
        }
 /// <summary>
 ///     Repopulates the session.
 /// </summary>
 /// <param name = "userName">Name of the user.</param>
 /// <returns></returns>
 /// <author>nate</author>
 /// <datetime>6/17/2011-10:06 AM</datetime>
 private static bool RepopulateSession(string userName)
 {
     if (userName != "" && Utilities.IsEmail(userName))
     {
         HttpContext.Current.Session.RemoveAll();
         var currentUser = new CurrentUserObj(userName);
         HttpContext.Current.Session["currentUser"] = currentUser;
         return(true);
     }
     return(false);
 }