Esempio n. 1
0
        public ActionResult Account()
        {
            // Should have been redirected here as a result of a LinkedIn login so check there is a profile.

            var profile = _linkedInQuery.GetProfile(CurrentAnonymousUser.Id);

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

            return(View(GetAccountModel(new Login(), profile)));
        }
Esempio n. 2
0
        public void TestLoginIdLinkedInProfile()
        {
            var employer = CreateEmployer(0);

            _linkedInCommand.UpdateProfile(new LinkedInProfile {
                Id = LinkedInId, UserId = employer.Id
            });

            LogIn(employer);
            Get(_settingsUrl);
            AssertLinkedInProfile(employer.GetLoginId(), false, true);

            // Try to update.

            _useLinkedInProfileCheckBox.IsChecked = false;
            _saveButton.Click();
            AssertUrlWithoutQuery(LoggedInEmployerHomeUrl);

            // Assert profile.

            Assert.IsNull(_linkedInQuery.GetProfile(LinkedInId));
            Assert.IsNull(_linkedInQuery.GetProfile(employer.Id));

            Get(_settingsUrl);
            AssertNoLinkedInProfile(employer.GetLoginId());
        }
Esempio n. 3
0
        public ActionResult Settings()
        {
            var employer = CurrentEmployer;

            var credentials = _loginCredentialsQuery.GetCredentials(employer.Id);

            var jobPoster = _jobPostersQuery.GetJobPoster(employer.Id) ?? new JobPoster {
                Id = employer.Id
            };
            var nonMemberSettings = _nonMemberSettingsQuery.GetNonMemberSettings(employer.EmailAddress.Address);

            var settings = _settingsQuery.GetSettings(employer.Id);
            var employerUpdateCategory = (from c in _settingsQuery.GetCategories(UserType.Employer) where c.Name == "EmployerUpdate" select c).Single();
            var campaignCategory       = (from c in _settingsQuery.GetCategories(UserType.Employer) where c.Name == "Campaign" select c).Single();

            var model = new SettingsModel
            {
                FirstName               = employer.FirstName,
                LastName                = employer.LastName,
                OrganisationName        = employer.Organisation.Name,
                CanEditOrganisationName = !employer.Organisation.IsVerified,
                Role                       = employer.SubRole,
                JobTitle                   = employer.JobTitle,
                EmailAddress               = employer.EmailAddress.Address,
                PhoneNumber                = employer.PhoneNumber == null ? null : employer.PhoneNumber.Number,
                IndustryIds                = employer.Industries == null ? new List <Guid>() : employer.Industries.Select(i => i.Id).ToList(),
                Industries                 = _industriesQuery.GetIndustries(),
                HasLoginCredentials        = credentials != null,
                LoginId                    = credentials == null ? null : credentials.LoginId,
                UseLinkedInProfile         = _linkedInQuery.GetProfile(employer.Id) != null,
                Allocations                = GetAllocations(employer),
                ShowSuggestedCandidates    = jobPoster.ShowSuggestedCandidates,
                SendSuggestedCandidates    = jobPoster.SendSuggestedCandidates,
                ReceiveSuggestedCandidates = nonMemberSettings == null || !nonMemberSettings.SuppressSuggestedCandidatesEmails,
                EmailEmployerUpdate        = EmailCategory(employerUpdateCategory, settings),
                EmailCampaign              = EmailCategory(campaignCategory, settings),
            };

            return(View(model));
        }
        AuthenticationResult ILinkedInAuthenticationCommand.AuthenticateUser(string linkedInId)
        {
            var profile = _linkedInQuery.GetProfile(linkedInId);

            if (profile == null)
            {
                return new AuthenticationResult {
                           Status = AuthenticationStatus.Failed
                }
            }
            ;

            var user = _usersQuery.GetUser(profile.UserId);

            if (user == null)
            {
                return new AuthenticationResult {
                           Status = AuthenticationStatus.Failed
                }
            }
            ;

            // Only support employers for now.

            if (user.UserType != UserType.Employer)
            {
                return new AuthenticationResult {
                           Status = AuthenticationStatus.Failed
                }
            }
            ;

            return(new AuthenticationResult
            {
                User = user,
                Status = GetAuthenticationStatus(user),
            });
        }
Esempio n. 5
0
 public void TestNoProfile()
 {
     Assert.IsNull(_linkedInQuery.GetProfile(LinkedInId));
     Assert.IsNull(_linkedInQuery.GetProfile(Guid.NewGuid()));
 }
Esempio n. 6
0
        public void TestAutoLogIn()
        {
            var profile  = CreateProfile();
            var employer = _employerAccountsCommand.CreateTestEmployer(0, _organisationsCommand.CreateTestOrganisation(0));

            profile.UserId = employer.Id;
            _linkedInCommand.UpdateProfile(profile);

            // Login.

            Get(EmployerLogInUrl);
            AssertUrl(EmployerLogInUrl);
            AssertAutoAuthorize(false);

            var url = LinkedInApiLogIn(AuthenticationStatus.Authenticated, CreateApiProfile());

            Assert.AreEqual(EmployerHomeUrl.PathAndQuery.ToLower(), url.PathAndQuery.ToLower());

            // Confirm logged in.

            Get(url);
            AssertUrl(LoggedInEmployerHomeUrl);

            // Profile should not have changed.

            AssertProfile(profile, _linkedInQuery.GetProfile(LinkedInId));
            AssertProfile(profile, _linkedInQuery.GetProfile(employer.Id));

            // Logout.

            LogOut();
            AssertUrl(EmployerHomeUrl);
            AssertAutoAuthorize(true);

            Get(EmployerLogInUrl);
            AssertAutoAuthorize(true);
        }