Starts in:
2 DAYS
16 HRS
14 MIN
0 SEC
Starts in:
2 D
16 H
14 M
0 S

Activities of "bhyatz"

Answer

Hi

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

Answer

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?

Answer

Hi Alper

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

Answer

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);
        }
Answer

Angular

Showing 11 to 15 of 15 entries
Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06