Ejemplo n.º 1
0
        public ActionResult Login(string email)
        {
            var user = _userContextService.GetCurrentContext();

            if (user.IsCofoundryUser())
            {
                return(GetLoggedInDefaultRedirectAction());
            }

            var viewPath = ViewPathFormatter.View(CONTROLLER_NAME, nameof(Login));
            var vm       = new LoginViewModel {
                EmailAddress = email
            };

            return(View(viewPath, vm));
        }
        public AuthenticationResult LogUserIn(Controller controller, ILoginViewModel vm, IUserAreaDefinition userAreaToLogInTo)
        {
            Condition.Requires(controller).IsNotNull();
            Condition.Requires(userAreaToLogInTo).IsNotNull();
            Condition.Requires(vm).IsNotNull();

            var result = new AuthenticationResult();

            result.ReturnUrl = controller.Request["ReturnUrl"];
            if (!controller.ModelState.IsValid)
            {
                return(result);
            }

            var command = new LogUserInWithCredentialsCommand()
            {
                UserAreaCode = userAreaToLogInTo.UserAreaCode,
                Username     = vm.EmailAddress,
                Password     = vm.Password,
                RememberUser = vm.RememberMe
            };

            _controllerResponseHelper.ExecuteIfValid(controller, command);

            if (controller.ModelState.IsValid)
            {
                result.IsAuthenticated = true;
                var currentContext = _userContextService.GetCurrentContext();
                result.RequiresPasswordChange = currentContext.IsPasswordChangeRequired;
            }

            return(result);
        }
Ejemplo n.º 3
0
        public Task ExecuteAsync(Controller controller, PageActionRoutingState state)
        {
            state.UserContext = _userContextService.GetCurrentContext();

            // Work out whether to view the page in live/draft/edit mode.
            // We use live by default (for logged out users) or for authenticated
            // users we can show draft too.
            var visualEditorMode = VisualEditorMode.Live;

            if (state.UserContext.IsCofoundryUser())
            {
                if (state.InputParameters.VersionId.HasValue)
                {
                    visualEditorMode = VisualEditorMode.SpecificVersion;
                }
                else if (!Enum.TryParse(state.InputParameters.VisualEditorMode, true, out visualEditorMode))
                {
                    visualEditorMode = VisualEditorMode.Any;
                }
            }
            else if (_contentSettings.AlwaysShowUnpublishedData)
            {
                // We can optionally set the visual editor mode to any - ie show draft and published pages
                // This is used in scenarios where devs are making modifications against a live db using a
                // local debug version of the site but aren't ready to publish the pages yet.
                visualEditorMode = VisualEditorMode.Any;
            }
            state.VisualEditorMode = visualEditorMode;

            return(Task.FromResult(true));
        }
Ejemplo n.º 4
0
        public ActionResult Login(string email)
        {
            var user = _userContextService.GetCurrentContext();

            if (user.IsCofoundryUser())
            {
                return(GetLoggedInDefaultRedirectAction());
            }
            return(View(new LoginViewModel {
                EmailAddress = email
            }));
        }
Ejemplo n.º 5
0
 private IUserContext InitUserContext()
 {
     return(_userContextServiceService.GetCurrentContext());
 }
Ejemplo n.º 6
0
        public async Task <IHttpActionResult> Patch(Delta <UpdateCurrentUserAccountCommand> delta)
        {
            var userId = _userContextService.GetCurrentContext().UserId.Value;

            return(await _apiResponseHelper.RunCommandAsync(this, userId, delta));
        }
        public void InitViewModel(IChangePasswordViewModel vm)
        {
            var cx = _userContextService.GetCurrentContext();

            vm.IsPasswordChangeRequired = cx.IsPasswordChangeRequired;
        }
 /// <summary>
 /// Checks to see if the currently logged in user is in the super administrator role,
 /// if not, throws an exception.
 /// </summary>
 public void EnforceIsSuperAdminRole()
 {
     EnforceIsSuperAdminRole(_userContextService.GetCurrentContext());
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Creates an instance of IExecutionContext from the currently
 /// logged in user.
 /// </summary>
 public IExecutionContext Create()
 {
     return(Create(_userContextService.GetCurrentContext()));
 }