/// <summary>
        /// Replace old password service
        /// </summary>
        /// <param name="newCredentials">new user credentials</param>
        /// <returns>true if success else false</returns>
        public ResetPasswordResponseDTO ReplaceOldPassword(UserCredential newCredentials)
        {
            SetNewPassword setNewPassword = new SetNewPassword()
            {
                incommingCredentials = newCredentials
            };

            return((ResetPasswordResponseDTO)setNewPassword.Execute().Result);
        }
        public async Task <IActionResult> SetNewPasswordAsync([FromBody] SetNewPassword view)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessages()));
            }

            var result = await _service.SetNewPassword(view);

            return(Ok(result.User));
        }
        public void SuccessfulResetPass()
        {
            UserCredential newCredentials = new UserCredential("hi", "hellohello");

            SetNewPassword nouser = new SetNewPassword()
            {
                incommingCredentials = newCredentials
            };

            var response = (ResetPasswordResponseDTO)nouser.Execute().Result;

            Assert.True(response.isSuccessful);
        }
        public void UserDoesNotExist()
        {
            UserCredential newCredentials = new UserCredential("asdf", "asdf");

            SetNewPassword nouser = new SetNewPassword()
            {
                incommingCredentials = newCredentials
            };

            var response = (ResetPasswordResponseDTO)nouser.Execute().Result;

            Assert.False(response.isSuccessful);
        }
Example #5
0
        public void TestSetNewPassword_ItShouldSetNewPassoword_Success()
        {
            var sss = -2;

            var ttt = (int)(uint)sss;


            var token = _randomStringGeneratorService.Generate(25);


            var yy = new SetNewPassword()
            {
            };
            var mm = _accountService.SetNewPassword(yy);

            Assert.IsNotNull(mm);
        }
Example #6
0
        protected static void Initialize()
        {
            ExceptionHandlerMock = new Mock <IExceptionHandler>();
            Handler               = new Handler(ExceptionHandlerMock.Object);
            PasswordServiceMock   = new Mock <IPasswordService>();
            SetNewPasswordHandler = new SetNewPasswordHandler(Handler,
                                                              BusClientMock.Object, PasswordServiceMock.Object);

            Command = new SetNewPassword
            {
                Request = new Request
                {
                    Id        = Guid.NewGuid(),
                    CreatedAt = DateTime.Now,
                    Culture   = "en-US",
                    Name      = "name",
                    Origin    = "collectively",
                    Resource  = "resource"
                },
                Email    = "email",
                Password = "******",
                Token    = "token"
            };
        }
Example #7
0
 public async Task HandleAsync(SetNewPassword command)
 => await CreateAsync(command);
Example #8
0
        public AccountPanelViewModel()
        {
            SetNewPassword = ReactiveCommand.CreateFromObservable(
                () => SetNewPasswordImpl(_newPassword),
                this.WhenAnyValue(vm => vm.User, vm => vm.NewPassword, (user, password) => user != null && password.HasValue()));

            SetNewSimplePassword = ReactiveCommand.CreateFromObservable(SetNewSimplePasswordImpl);

            SetNewComplexPassword = ReactiveCommand.CreateFromObservable(SetNewComplexPasswordImpl);

            ExpirePassword = ReactiveCommand.CreateFromObservable(() => Messages.Handle(new MessageInfo(MessageType.Question, "Are you sure you want to expire the password?", "Expire password?", "Yes", "No"))
                                                                  .Where(result => result == 0)
                                                                  .SelectMany(_ => _adFacade.ExpirePassword(User.Principal.SamAccountName)));

            UnlockAccount = ReactiveCommand.CreateFromObservable(() => _adFacade.UnlockUser(User.Principal.SamAccountName));

            RunLockoutStatus = ReactiveCommand.Create(() => ExecutionService.RunFileFromCache("LockoutStatus", "LockoutStatus.exe", $"-u:{_adFacade.CurrentDomain}\\{User.Principal.SamAccountName}"));

            OpenPermittedWorkstations = ReactiveCommand.CreateFromObservable(() => _dialogRequests.Handle(new DialogInfo(new PermittedWorkstationsDialog(), _user.Principal.SamAccountName)));

            ToggleEnabled = ReactiveCommand.CreateFromObservable(() => _adFacade.SetEnabled(User.Principal.SamAccountName, !User.Principal.Enabled ?? true));

            OpenSplunk = ReactiveCommand.Create(() =>
            {
                Process.Start(string.Format(Locator.Current.GetService <SettingsFacade>().SplunkUrl, _adFacade.CurrentDomainShortName, User.Principal.SamAccountName));
            });

            this.WhenActivated(disposables =>
            {
                SetNewPassword
                .ObserveOnDispatcher()
                .Do(_ => NewPassword = "")
                .SelectMany(newPass => _messages.Handle(new MessageInfo(MessageType.Success, $"New password is: {newPass}", "Password set")))
                .Subscribe()
                .DisposeWith(disposables);

                SetNewSimplePassword
                .ObserveOnDispatcher()
                .SelectMany(newPass => _messages.Handle(MessageInfo.PasswordSetMessageInfo(newPass)))
                .Subscribe()
                .DisposeWith(disposables);

                SetNewComplexPassword
                .ObserveOnDispatcher()
                .SelectMany(newPass => _messages.Handle(MessageInfo.PasswordSetMessageInfo(newPass)))
                .Subscribe()
                .DisposeWith(disposables);

                ExpirePassword
                .SelectMany(_ => _messages.Handle(new MessageInfo(MessageType.Success, "User must change password at next login", "Password expired")))
                .Subscribe()
                .DisposeWith(disposables);

                UnlockAccount
                .SelectMany(_ =>
                {
                    MessageBus.Current.SendMessage(_user.CN, ApplicationActionRequest.Refresh);
                    return(_messages.Handle(new MessageInfo(MessageType.Success, "Account unlocked")));
                })
                .Subscribe()
                .DisposeWith(disposables);

                ToggleEnabled
                .Subscribe(_ => MessageBus.Current.SendMessage(_user.CN, ApplicationActionRequest.Refresh))
                .DisposeWith(disposables);


                Observable.Merge(
                    SetNewPassword.ThrownExceptions,
                    SetNewSimplePassword.ThrownExceptions,
                    SetNewComplexPassword.ThrownExceptions)
                .SelectMany(ex => _messages.Handle(MessageInfo.PasswordSetErrorMessageInfo(ex.Message)))
                .Subscribe()
                .DisposeWith(disposables);


                Observable.Merge <(string Title, string Message)>(
                    ExpirePassword.ThrownExceptions.Select(ex => ("Could not expire password", ex.Message)),
                    UnlockAccount.ThrownExceptions.Select(ex => ("Could not unlock acount", ex.Message)),
                    RunLockoutStatus.ThrownExceptions.Select(ex => ("Could not open LockOutStatus", ex.Message)),
                    OpenPermittedWorkstations.ThrownExceptions.Select(ex => ("Could not open Permitted Workstations", ex.Message)),
                    ToggleEnabled.ThrownExceptions.Select(ex => ("Could not toggle enabled status", ex.Message)))
                .SelectMany(dialogContent => _messages.Handle(new MessageInfo(MessageType.Error, dialogContent.Message, dialogContent.Title)))
                .Subscribe()
                .DisposeWith(disposables);
            });
        }