Exemple #1
0
        public void TestEmailLinks()
        {
            var administrator = _administratorAccountsCommand.CreateTestAdministrator(1);
            var campaign      = CreateCampaign(administrator);
            var member        = _memberAccountsCommand.CreateTestMember(0);

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

            // Send.

            var campaignEmail = _campaignEmailsCommand.CreateEmail(campaign, member);

            _campaignEmailsCommand.Send(new[] { campaignEmail }, campaign.Id, false);

            var email = _emailServer.AssertEmailSent();

            var links = email.GetHtmlView().GetLinks();

            Assert.AreEqual(12, links.Count);

            const string definition = "ReengagementEmail";

            AssertActivationLink(member, false, definition, new ReadOnlyApplicationUrl("~/"), links[0]);
            AssertActivationLink(member, false, definition, new ReadOnlyApplicationUrl("~/search/jobs"), links[1]);
            AssertActivationLink(member, false, definition, new ReadOnlyApplicationUrl(true, "~/login"), links[2]);
            AssertActivationLink(member, true, definition, new ReadOnlyApplicationUrl(true, "~/members/profile"), links[3]);
            AssertActivationLink(member, true, definition, new ReadOnlyApplicationUrl(true, "~/members/profile"), links[4]);
            AssertActivationLink(member, false, definition, new ReadOnlyApplicationUrl("~/"), links[5]);
            AssertActivationLink(member, false, definition, new ReadOnlyApplicationUrl("~/members/resources"), links[6]);
            AssertActivationLink(member, true, definition, new ReadOnlyApplicationUrl(true, "~/members/profile"), links[7]);
            AssertActivationLink(member, true, definition, new ReadOnlyApplicationUrl(true, "~/members/profile"), links[8]);
            AssertActivationLink(member, false, definition, new ReadOnlyApplicationUrl("~/"), links[9]);
            AssertActivationLink(member, true, definition, new ReadOnlyApplicationUrl(true, "~/members/settings"), links[10]);
            AssertActivationLink(member, false, definition, new ReadOnlyApplicationUrl(true, "~/accounts/settings/unsubscribe", new ReadOnlyQueryString("userId", member.Id.ToString(), "category", "Campaign")), links[11]);

            links = email.GetPlainTextView().GetPlainTextLinks();
            Assert.AreEqual(9, links.Count);

            AssertActivationLink(member, false, definition, new ReadOnlyApplicationUrl("~/search/jobs"), links[0]);
            AssertActivationLink(member, false, definition, new ReadOnlyApplicationUrl(true, "~/login"), links[1]);
            AssertActivationLink(member, true, definition, new ReadOnlyApplicationUrl(true, "~/members/profile"), links[2]);
            AssertActivationLink(member, true, definition, new ReadOnlyApplicationUrl(true, "~/members/profile"), links[3]);
            AssertActivationLink(member, false, definition, new ReadOnlyApplicationUrl("~/members/resources"), links[4]);
            AssertActivationLink(member, true, definition, new ReadOnlyApplicationUrl(true, "~/members/profile"), links[5]);
            AssertActivationLink(member, true, definition, new ReadOnlyApplicationUrl(true, "~/members/profile"), links[6]);
            AssertActivationLink(member, true, definition, new ReadOnlyApplicationUrl(true, "~/members/settings"), links[7]);
            AssertActivationLink(member, false, definition, new ReadOnlyApplicationUrl(true, "~/accounts/settings/unsubscribe", new ReadOnlyQueryString("userId", member.Id.ToString(), "category", "Campaign")), links[8]);
        }
Exemple #2
0
        public void TestActivated()
        {
            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));

            // Deactivate.

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

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

            // Activate.

            _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));
        }
Exemple #3
0
        public void TestActivated()
        {
            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));

            // Deactivate.

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

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

            // Activate.

            _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));
        }
Exemple #4
0
        public void TestDeactivated()
        {
            var campaign = CreateCampaign();

            _campaignsCommand.UpdateStatus(campaign, CampaignStatus.Activated);

            // Create members.

            var member = CreateMembers(0, 1)[0];

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

            // Execute.

            new CampaignsTask().ExecuteTask();
            var emails = _emailServer.AssertEmailsSent(1);

            AssertEmails(new[] { member }, emails);

            // Should now be stopped.

            new CampaignsTask().ExecuteTask();
            _emailServer.AssertNoEmailSent();

            campaign = _campaignsQuery.GetCampaign(campaign.Id);
            Assert.AreEqual(CampaignStatus.Stopped, campaign.Status);
        }
Exemple #5
0
        public void TestDeactivatedMember()
        {
            // Create the member.

            var member = _memberAccountsCommand.CreateTestMember(0);

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

            // Login.

            AssertNotLoggedIn();
            AssertJsonSuccess(ApiLogIn(member));

            // Assert that the user was redirected to the account not activated form.

            Get(HomeUrl);
            AssertPath(_notActivatedUrl);
        }
        public ActionResult Deactivate(Guid id)
        {
            var member = _membersQuery.GetMember(id);

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

            _userAccountsCommand.DeactivateUserAccount(member, User.Id().Value);
            return(RedirectToRoute(MembersRoutes.Edit, new { id }));
        }
Exemple #7
0
        public void TestDeactivatedMember()
        {
            // Create the member.

            var member = _memberAccountsCommand.CreateTestMember(0);

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

            // Assert that the user is not already logged in.

            GetLoginUrl();
            AssertPageDoesNotContain(member.FullName);

            // Log in.

            SubmitLogIn(member);

            // Assert that the user was redirected to the account not activated form.

            AssertUrl(_notActivatedUrl);
        }
Exemple #8
0
        public void TestDeactivatedProfile()
        {
            var employer = _employerAccountsCommand.CreateTestEmployer(0, _organisationsCommand.CreateTestOrganisation(0));

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

            var profile = new LinkedInProfile
            {
                Id     = LinkedInId,
                UserId = employer.Id,
            };

            _linkedInCommand.UpdateProfile(profile);

            var result = _linkedInAuthenticationCommand.AuthenticateUser(LinkedInId);

            Assert.AreEqual(AuthenticationStatus.Deactivated, result.Status);
            Assert.AreEqual(employer.Id, result.User.Id);
        }
Exemple #9
0
        public ActionResult Deactivate([Bind(Include = "Reasons")] DeactivationReason?reasons, [Bind(Include = "Comments")] string comments)
        {
            // Set defaults and truncate the comments if needed.  Don't report any errors etc to the user while they are trying to deactivate.

            if (reasons == null)
            {
                ModelState.AddModelError(new[] { new RequiredValidationError("reason") }, new StandardErrorHandler());
                return(View());
            }

            comments = TextUtil.Truncate(comments, Constants.MaxDeactivationCommentsLength);

            _userAccountsCommand.DeactivateUserAccount(CurrentRegisteredUser, reasons.Value, comments);

            // Log out.

            _authenticationManager.LogOut(HttpContext);

            // Redirect straight to the default page using HTTP, otherwise HTTPS will be used if the current page is secure.

            return(RedirectToUrl(new ReadOnlyApplicationUrl(false, NavigationManager.GetHomeUrl().PathAndQuery)));
        }