"bhyatz" की गतिविधियाँ

उत्तर

Hi

I am getting the following error, I have tried the above and it is still not working. I only develop on one computer.

उत्तर

According to https://github.com/abpframework/abp/issues/1082 this has been added to backlog with priority high, do you have an idea when this would be implemented?

उत्तर

Hi Alper

We are using the angular ui , not mvc. How would you do this on the angular ui?

उत्तर

I am not sure if this is the correct way. I created my own IResourceOwnerPasswordValidator that extends AbpResourceOwnerPasswordValidator. I modified ValidateAsync to include my own rules and than called await base.ValidateAsync(context);

public override async Task ValidateAsync(ResourceOwnerPasswordValidationContext context)
        {
            await ReplaceEmailToUsernameOfInputIfNeeds(context).ConfigureAwait(false);

            var user = _abUserManager.GetUser(context.UserName);
            if (user != null)
            {
                var now = DateTime.Now;

                if (user.ValidFromDate.CompareTo(now) > 0 || user.ValidToInclDate.AddDays(1).CompareTo(now) < 0)
                {
                    _logger.LogInformation("User not in valid from and valid to dates : {username}", context.UserName);
                    await _events.RaiseAsync(new UserLoginFailureEvent(context.UserName, "login not valid for dates", interactive: false)).ConfigureAwait(false);
                    context.Result = new GrantValidationResult(TokenRequestErrors.InvalidGrant,"User Login not valid for current Date");
                }
                else if(!user.Active)
                {
                    _logger.LogInformation("User is deactivated : {username}", context.UserName);
                    await _events.RaiseAsync(new UserLoginFailureEvent(context.UserName, "is deactivated", interactive: false)).ConfigureAwait(false);
                    context.Result = new GrantValidationResult(TokenRequestErrors.InvalidGrant, "User is deactivated");
                }
                else
                {
                    await base.ValidateAsync(context);
                }
            }
            else
            {
                _logger.LogInformation("No user found matching username: {username}", context.UserName);
                await _events.RaiseAsync(new UserLoginFailureEvent(context.UserName, "invalid username", interactive: false)).ConfigureAwait(false);
                context.Result = new GrantValidationResult(TokenRequestErrors.InvalidGrant);
            }
        }

I also createe my own service to add users with the extra properties. I first create the user using the injected IAbUserManager and then update the user using the custom user respository

public override async Task<AbUserDto> CreateAsync(AbUserCreateDto input)
        {
            var user = _abUserManager.GetUser(input.Username);

            if (user != null)
            {
                throw new BusinessException(AumErrorCodes.UserNameExists);
            }

            await ValidateInput(input.PhoneNumbers,input.PersonTypeId,input.CompanyId);
            var emailAddress = input.EmailAddresses.First().EmailAddress;

            var userId  = await _abUserManager.CreateUserAsync(input.Username, input.Password, emailAddress,
            input.ValidFromDate, input.ValidToInclDate, input.Active, input.DeactivationReason);

            input.AbpUserId = userId;

            return await base.CreateAsync(input);
        }
उत्तर

Angular

15 प्रविष्टियों में 11 से 15 दिखा रहा है
Made with ❤️ on ABP v8.2.0-preview Updated on मार्च 25, 2024, 15:11