private void doLogin()
        {
            //blow out any existing member when someone tries to sign in
            try
            {
                //Reset session backed my groups from Whats Happening Now
                Session["_selectedGroups"] = null;

                //lets make sure to reset all user&member info before we start inflating it
                this.FlushCurrentMemberUser();

                var membershipManager = new MembershipManager();

                var currentMember = new Member();

                if (!string.IsNullOrEmpty(AccessToken))
                {
                    var     client = new Facebook.FacebookClient(AccessToken);
                    dynamic me     = client.Get("me", new { fields = "email" });

                    currentMember = membershipManager.GetMember(me.email);
                }
                else
                {
                    currentMember = membershipManager.AuthenticateUser(uxEmailAddress.Text, uxPassword.Text);
                }

                if (currentMember != null)
                {
                    this.CurrentMember = currentMember;
                    this.CurrentUser   = membershipManager.GetUser(currentMember.MemberId, true);

                    this.ProfileRedirect(Constants.UserPermission.AgreedToTerms, null, true);

                    //Redirect used here for profile??
                    this.ReturnRedirect();

                    var item = Sitecore.Context.Database.GetItem(Constants.Pages.MyAccount);
                    // if you get this far, clear the redirect session URL

                    Response.Redirect(Sitecore.Links.LinkManager.GetItemUrl(item));
                }
            }
            catch (Exception ex)
            {
                uxError.Text = ex.Message;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Authenticates the user.
        /// </summary>
        private void AuthenticateUser()
        {
            if (tbEmail.Text.IsEmailValid())
            {
                mm = new MembershipManager();

                UserDTO possibleUser = new UserDTO();

                possibleUser.UserName = tbEmail.Text.ToLower();

                PasswordHasher ph   = new PasswordHasher(applicationViewModel.KeyForUserPasswordSalt);
                string         salt = ph.CreateSalt(possibleUser.UserName);
                possibleUser.PasswordHash = ph.HashPassword(salt, tbPassword.Password);

                mm.AuthenticateUser(possibleUser);
                mm.UserAuthenticated    += new MembershipManager.UserAuthenticatedHandler(mm_UserAuthenticated);
                mm.UserNotAuthenticated += new System.EventHandler(mm_UserNotAuthenticated);
            }
            else
            {
                spMsg.Visibility    = System.Windows.Visibility.Visible;
                tbPassword.Password = "";
            }
        }