public async Task User_should_be_able_to_change_password()
        {
            var createdResult = await UserManagementApi.CreateUser(GetUniqueTestUser);

            var passwordRequest = new PasswordForgottenRequest
            {
                Username = createdResult.Data.First().Username
            };

            var tokenResult = await UserManagementApi.GetPasswordResetToken(passwordRequest);

            var tokenData = tokenResult.Data.First();

            var newPasswordRequest = new PasswordForgottenNewPassword
            {
                Username = tokenData.Username,
                Token    = tokenData.Token,
                Password = "******"
            };

            var changePasswordResult = await UserManagementApi.SetNewPasswordAfterReset(newPasswordRequest);

            Assert.True(createdResult.Success);
            Assert.True(tokenResult.Success);
            Assert.True(changePasswordResult.Success);
        }
        public async Task User_should_be_able_to_change_password()
        {
            var(resultCreated, userCreated) = await UserTenantManagementApi.CreateUser(UniqueTestUser).UnpackSingleOrDefault();

            var passwordRequest = new PasswordForgottenRequest
            {
                Username = userCreated.Username
            };

            var(resultToken, tokenData) = await UserTenantManagementApi.GetPasswordResetToken(passwordRequest).UnpackSingleOrDefault();

            var newPasswordRequest = new PasswordForgottenNewPassword
            {
                Username = tokenData.Username,
                Token    = tokenData.Token,
                Password = "******"
            };

            var changePasswordResult = await UserTenantManagementApi.SetNewPasswordAfterReset(newPasswordRequest);

            Assert.True(resultCreated.Success);
            Assert.True(resultToken.Success);
            Assert.True(changePasswordResult.Success);
        }
Esempio n. 3
0
        public virtual async Task <IdentityUtilsResult <PasswordForgottenResponse> > GetPasswordResetToken([FromBody] PasswordForgottenRequest passwordForgottenRequest)
        {
            var userResult = await userManager.FindByNameAsync(passwordForgottenRequest.Username);

            if (!userResult.Success)
            {
                return(userResult.ToTypedResult <PasswordForgottenResponse>());
            }

            var resetTokenResult = await userManager.GeneratePasswordResetTokenAsync(passwordForgottenRequest.Username);

            if (!resetTokenResult.Success)
            {
                return(resetTokenResult.ToTypedResult <PasswordForgottenResponse>());
            }

            var userData         = userResult.Data.First();
            var passwordResponse = new PasswordForgottenResponse
            {
                Username = userData.UserName,
                Email    = userData.Email,
                Token    = resetTokenResult.Data.First()
            };

            return(IdentityUtilsResult <PasswordForgottenResponse> .SuccessResult(passwordResponse));
        }
 public Task <IdentityUtilsResult <PasswordForgottenResponse> > GetPasswordResetToken(PasswordForgottenRequest passwordForgottenRequest)
 => RestClient.Post <IdentityUtilsResult <PasswordForgottenResponse> >($"{BasePath}/passwordreset", passwordForgottenRequest).ParseRestResultTask();