public ActionResult GatewayInform(string hashedAccountId) { if (!string.IsNullOrWhiteSpace(hashedAccountId)) { _accountCookieStorage.Delete(_hashedAccountIdCookieName); _accountCookieStorage.Create( new HashedAccountIdModel { Value = hashedAccountId }, _hashedAccountIdCookieName); } var gatewayInformViewModel = new OrchestratorResponse <GatewayInformViewModel> { Data = new GatewayInformViewModel { BreadcrumbDescription = "Back to Your User Profile", ConfirmUrl = Url.Action(ControllerConstants.GatewayViewName, ControllerConstants.EmployerAccountControllerName), } }; var flashMessageViewModel = GetFlashMessageViewModelFromCookie(); if (flashMessageViewModel != null) { gatewayInformViewModel.FlashMessage = flashMessageViewModel; } return(View(gatewayInformViewModel)); }
protected void SetInfoMessage(string messageText, FlashMessageSeverityLevel level) { var message = new FlashMessageViewModel { Message = messageText, Severity = level }; _flashMessage.Delete(FlashMessageCookieName); _flashMessage.Create(message, FlashMessageCookieName); }
public async Task <OrchestratorResponse <SearchOrganisationResultsViewModel> > SearchOrganisation(string searchTerm, int pageNumber, OrganisationType?organisationType, string hashedAccountId, string userId) { var response = new OrchestratorResponse <SearchOrganisationResultsViewModel>(); try { _cookieService.Delete(CookieName); var result = await Mediator.SendAsync(new GetOrganisationsRequest { SearchTerm = searchTerm, PageNumber = pageNumber, OrganisationType = organisationType }); response.Data = new SearchOrganisationResultsViewModel { Results = CreateResult(result.Organisations), SearchTerm = searchTerm, OrganisationType = organisationType }; if (!string.IsNullOrEmpty(hashedAccountId)) { await SetAlreadySelectedOrganisations(hashedAccountId, userId, response.Data.Results); } } catch (InvalidRequestException ex) { response.Exception = ex; response.FlashMessage = FlashMessageViewModel.CreateErrorFlashMessageViewModel(ex.ErrorMessages); response.Status = HttpStatusCode.BadRequest; } return(response); }
public async Task <ActionResult> SkipRegistration() { var request = new CreateUserAccountViewModel { UserId = GetUserId(), OrganisationName = "MY ACCOUNT" }; var response = await _employerAccountOrchestrator.CreateMinimalUserAccountForSkipJourney(request, HttpContext); var returnUrlCookie = _returnUrlCookieStorageService.Get(ReturnUrlCookieName); _returnUrlCookieStorageService.Delete(ReturnUrlCookieName); if (returnUrlCookie != null && !returnUrlCookie.Value.IsNullOrWhiteSpace()) { return(Redirect(returnUrlCookie.Value)); } return(RedirectToAction(ControllerConstants.IndexActionName, ControllerConstants.EmployerTeamControllerName, new { hashedAccountId = response.Data.HashedId })); }
private void SaveContext(OrchestratorResponse <AccountDashboardViewModel> orchestratorResponse) { if (orchestratorResponse.Status == HttpStatusCode.OK) { _accountContext.Delete(AccountContextCookieName); _accountContext.Create( new AccountContext { HashedAccountId = orchestratorResponse.Data.HashedAccountId, ApprenticeshipEmployerType = orchestratorResponse.Data.ApprenticeshipEmployerType } , AccountContextCookieName); } }
private LocationCookieItem CheckLocation(string location) { if (location == "-1") { _locationCookieStorageService.Delete(Constants.LocationCookieName); return(null); } if (string.IsNullOrEmpty(location)) { return(_locationCookieStorageService.Get(Constants.LocationCookieName)); } return(new LocationCookieItem { Name = location }); }
private static void PostAuthentiationAction(ClaimsIdentity identity, Constants constants, ICookieStorageService <EmployerAccountData> accountDataCookieStorageService, ICookieStorageService <HashedAccountIdModel> hashedAccountIdCookieStorageService) { Logger.Info("Retrieving claims from OIDC server."); var userRef = identity.Claims.FirstOrDefault(claim => claim.Type == constants.Id())?.Value; Logger.Info($"Retrieved claims from OIDC server for user with external ID '{userRef}'."); identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, identity.Claims.First(c => c.Type == constants.Id()).Value)); identity.AddClaim(new Claim(ClaimTypes.Name, identity.Claims.First(c => c.Type == constants.DisplayName()).Value)); identity.AddClaim(new Claim("sub", identity.Claims.First(c => c.Type == constants.Id()).Value)); identity.AddClaim(new Claim("email", identity.Claims.First(c => c.Type == constants.Email()).Value)); identity.AddClaim(new Claim("firstname", identity.Claims.First(c => c.Type == constants.GivenName()).Value)); identity.AddClaim(new Claim("lastname", identity.Claims.First(c => c.Type == constants.FamilyName()).Value)); Task.Run(() => accountDataCookieStorageService.Delete(AccountDataCookieName)).Wait(); Task.Run(() => hashedAccountIdCookieStorageService.Delete(typeof(HashedAccountIdModel).FullName)).Wait(); }
public async Task <ActionResult> SearchPensionRegulatorByAorn(string payeRef, string aorn, string hashedAccountId) { if (!string.IsNullOrWhiteSpace(hashedAccountId)) { _accountCookieStorage.Delete(typeof(HashedAccountIdModel).FullName); _accountCookieStorage.Create( new HashedAccountIdModel { Value = hashedAccountId }, typeof(HashedAccountIdModel).FullName); } var userRef = OwinWrapper.GetClaimValue(ControllerConstants.UserRefClaimKeyName); var aornLock = await _mediatr.SendAsync(new GetUserAornLockRequest { UserRef = userRef }); if (!string.IsNullOrWhiteSpace(payeRef) && !string.IsNullOrWhiteSpace(aorn)) { return(await PerformSearchPensionRegulatorByAorn(new SearchPensionRegulatorByAornViewModel { Aorn = aorn, PayeRef = payeRef, IsLocked = aornLock.UserAornStatus.IsLocked, RemainingAttempts = aornLock.UserAornStatus.RemainingAttempts, AllowedAttempts = aornLock.UserAornStatus.AllowedAttempts, RemainingLock = aornLock.UserAornStatus.RemainingLock })); } return(View(ControllerConstants.SearchUsingAornViewName, new SearchPensionRegulatorByAornViewModel { IsLocked = aornLock.UserAornStatus.IsLocked, RemainingAttempts = aornLock.UserAornStatus.RemainingAttempts, AllowedAttempts = aornLock.UserAornStatus.AllowedAttempts, RemainingLock = aornLock.UserAornStatus.RemainingLock })); }
public void AddFlashMessageToCookie(FlashMessageViewModel model) { _flashMessage.Delete(FlashMessageCookieName); _flashMessage.Create(model, FlashMessageCookieName); }
public void CreateApprenticeshipViewModelCookie(UpdateApprenticeshipViewModel model) { _apprenticshipsViewModelCookieStorageService.Delete(CookieName); model.OriginalApprenticeship = null; _apprenticshipsViewModelCookieStorageService.Create(model, CookieName); }
private void SaveRequestStatusInCookie(RequestStatus status) { _lastCohortCookieStorageService.Delete(LastCohortPageCookieKey); _lastCohortCookieStorageService.Create(status.ToString(), LastCohortPageCookieKey); }
public void SetCookie(ApprenticeshipFiltersViewModel filtersViewModel) { _filterCookieStorageService.Delete(nameof(ApprenticeshipFiltersViewModel)); _filterCookieStorageService.Create(filtersViewModel, nameof(ApprenticeshipFiltersViewModel)); }