Exemple #1
0
        public void TestEnabled()
        {
            var employer = _employersCommand.CreateTestEmployer(0, _organisationsCommand.CreateTestOrganisation(0));

            _userAccountsCommand.EnableUserAccount(employer, Guid.NewGuid());
            _userAccountsCommand.ActivateUserAccount(employer, Guid.NewGuid());

            employer = _employersQuery.GetEmployer(employer.Id);
            Assert.IsTrue(employer.IsEnabled);
            Assert.IsTrue(employer.IsActivated);
            Assert.IsTrue(_userAccountsQuery.IsEnabled(employer.Id));
            Assert.IsTrue(_userAccountsQuery.IsActive(employer.Id));

            // Disable.

            _userAccountsCommand.DisableUserAccount(employer, Guid.NewGuid());

            employer = _employersQuery.GetEmployer(employer.Id);
            Assert.IsFalse(employer.IsEnabled);
            Assert.IsTrue(employer.IsActivated);
            Assert.IsFalse(_userAccountsQuery.IsEnabled(employer.Id));
            Assert.IsFalse(_userAccountsQuery.IsActive(employer.Id));

            // Enable.

            _userAccountsCommand.EnableUserAccount(employer, Guid.NewGuid());

            employer = _employersQuery.GetEmployer(employer.Id);
            Assert.IsTrue(employer.IsEnabled);
            Assert.IsTrue(employer.IsActivated);
            Assert.IsTrue(_userAccountsQuery.IsEnabled(employer.Id));
            Assert.IsTrue(_userAccountsQuery.IsActive(employer.Id));
        }
Exemple #2
0
        public void TestEnabled()
        {
            var member = _membersCommand.CreateTestMember(0);

            _userAccountsCommand.EnableUserAccount(member, Guid.NewGuid());
            _userAccountsCommand.ActivateUserAccount(member, Guid.NewGuid());

            member = _membersQuery.GetMember(member.Id);
            Assert.IsTrue(member.IsEnabled);
            Assert.IsTrue(member.IsActivated);
            Assert.IsTrue(_userAccountsQuery.IsEnabled(member.Id));
            Assert.IsTrue(_userAccountsQuery.IsActive(member.Id));

            // Disable.

            _userAccountsCommand.DisableUserAccount(member, Guid.NewGuid());

            member = _membersQuery.GetMember(member.Id);
            Assert.IsFalse(member.IsEnabled);
            Assert.IsTrue(member.IsActivated);
            Assert.IsFalse(_userAccountsQuery.IsEnabled(member.Id));
            Assert.IsFalse(_userAccountsQuery.IsActive(member.Id));

            // Enable.

            _userAccountsCommand.EnableUserAccount(member, Guid.NewGuid());

            member = _membersQuery.GetMember(member.Id);
            Assert.IsTrue(member.IsEnabled);
            Assert.IsTrue(member.IsActivated);
            Assert.IsTrue(_userAccountsQuery.IsEnabled(member.Id));
            Assert.IsTrue(_userAccountsQuery.IsActive(member.Id));
        }
Exemple #3
0
        private IRegisteredUser AuthenticateUser(Guid verticalId, ExternalUserData userData)
        {
            var result = _externalAuthenticationCommand.AuthenticateUser(new ExternalCredentials {
                ProviderId = verticalId, ExternalId = userData.ExternalId
            });

            switch (result.Status)
            {
            case AuthenticationStatus.Authenticated:
                return(UpdateMember(result.User, verticalId, userData));

            case AuthenticationStatus.Deactivated:

                // Shouldn't be deactivated so activate them now.

                _userAccountsCommand.ActivateUserAccount(result.User, result.User.Id);
                return(UpdateMember(result.User, verticalId, userData));

            case AuthenticationStatus.Failed:

                // Haven't seen this person before so create them an account.

                return(CreateMember(verticalId, userData));

            default:

                // Nothing that can be done here.

                return(null);
            }
        }
        public ActionResult Activate(Guid id)
        {
            var member = _membersQuery.GetMember(id);

            if (member == null)
            {
                return(NotFound("member", "id", id));
            }

            _userAccountsCommand.ActivateUserAccount(member, User.Id().Value);
            return(RedirectToRoute(MembersRoutes.Edit, new { id }));
        }
Exemple #5
0
        public ActionResult LogIn(Login loginModel, [Bind(Include = "RememberMe")] CheckBoxValue rememberMe)
        {
            var profile = _linkedInQuery.GetProfile(CurrentAnonymousUser.Id);

            if (profile == null)
            {
                return(RedirectToRoute(HomeRoutes.Home));
            }

            try
            {
                loginModel            = loginModel ?? new Login();
                loginModel.RememberMe = rememberMe != null && rememberMe.IsChecked;
                var result = _accountsManager.LogIn(HttpContext, loginModel);

                // Go to the next page.

                switch (result.Status)
                {
                case AuthenticationStatus.Disabled:

                    // If they are disabled, simply redirect them.

                    var faq = _faqsQuery.GetFaq(DisableFaqId);
                    return(RedirectToUrl(faq.GenerateUrl(_faqsQuery.GetCategories())));

                case AuthenticationStatus.Failed:
                    throw new AuthenticationFailedException();

                case AuthenticationStatus.Deactivated:

                    // Activate them.

                    _userAccountsCommand.ActivateUserAccount(result.User, result.User.Id);
                    break;
                }

                // The user has been authenticated so associate them with the LinkedIn profile.

                profile.UserId = result.User.Id;
                _linkedInCommand.UpdateProfile(profile);

                return(RedirectToReturnUrl());
            }
            catch (UserException ex)
            {
                ModelState.AddModelError(ex, new StandardErrorHandler());
            }

            return(View("Account", GetAccountModel(loginModel, profile)));
        }
        private Guid?Activate(Member member, EmailVerification emailVerification)
        {
            var emailAddress = (from a in member.EmailAddresses where string.Equals(a.Address, emailVerification.EmailAddress, StringComparison.InvariantCultureIgnoreCase) select a).SingleOrDefault();

            if (emailAddress == null)
            {
                return(null);
            }

            // Activate the account.

            _userAccountsCommand.ActivateUserAccount(member, member.Id);

            // Verify the email address.

            _emailVerificationsCommand.VerifyEmailAddress(member.Id, emailAddress.Address);

            return(member.Id);
        }
        private bool LogIn(string linkedInProfileId)
        {
            var result = _linkedInAuthenticationCommand.AuthenticateUser(linkedInProfileId);

            switch (result.Status)
            {
            case AuthenticationStatus.Authenticated:
                _authenticationManager.LogIn(HttpContext, result.User, AuthenticationStatus.Authenticated);
                return(true);

            case AuthenticationStatus.Deactivated:

                // If they are logging in with their LinkedIn credentials assume they are activated.

                _userAccountsCommand.ActivateUserAccount(result.User, result.User.Id);
                _authenticationManager.LogIn(HttpContext, result.User, AuthenticationStatus.Authenticated);
                return(true);

            default:
                return(false);
            }
        }
Exemple #8
0
        public void TestNewMember()
        {
            // Join.

            Get(_joinUrl);
            Browser.Submit(_joinFormId);

            _firstNameTextBox.Text          = FirstName;
            _lastNameTextBox.Text           = LastName;
            _emailAddressTextBox.Text       = EmailAddress;
            _phoneNumberTextBox.Text        = MobilePhoneNumber;
            _locationTextBox.Text           = Location;
            _salaryLowerBoundTextBox.Text   = SalaryLowerBound.ToString(CultureInfo.InvariantCulture);
            _openToOffersCheckBox.IsChecked = true;
            _passwordTextBox.Text           = Password;
            _confirmPasswordTextBox.Text    = Password;
            _acceptTermsCheckBox.IsChecked  = true;
            Browser.Submit(_personalDetailsFormId);

            // As this is the first log in the user should be at home page.

            var memberId = _loginCredentialsQuery.GetUserId(EmailAddress).Value;

            _userAccountsCommand.ActivateUserAccount(new Member {
                Id = memberId
            }, memberId);

            Get(LoggedInMemberHomeUrl);
            AssertUrl(LoggedInMemberHomeUrl);
            AssertNoProfilePrompt();
            AssertNoProfileReminder();
            AssertNoTermsReminder();
            AssertMemberState(false, true, false, true, memberId);

            // Get the page again.

            Get(LoggedInMemberHomeUrl);
            AssertUrl(LoggedInMemberHomeUrl);
            AssertNoProfilePrompt();
            AssertNoProfileReminder();
            AssertNoTermsReminder();
            AssertMemberState(false, true, false, true, memberId);

            // Go to the profile page.

            Get(_profileUrl);
            AssertUrl(_profileUrl);

            // Go back to the home page.

            Get(LoggedInMemberHomeUrl);
            AssertUrl(LoggedInMemberHomeUrl);
            AssertNoProfilePrompt();
            AssertNoProfileReminder();
            AssertNoTermsReminder();
            AssertMemberState(false, true, false, true, memberId);

            // Go to the terms page.

            Get(_termsUrl);
            AssertUrl(_termsUrl);

            // Go back to the home page.

            Get(LoggedInMemberHomeUrl);
            AssertUrl(LoggedInMemberHomeUrl);
            AssertNoProfilePrompt();
            AssertNoProfileReminder();
            AssertNoTermsReminder();
            AssertMemberState(false, true, false, true, memberId);
        }