Activities of "bhyatz"

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

I have added custom properties to Appuser /* Add your own properties here. Example: * * public virtual string MyProperty { get; set; } */ public virtual bool Active { get; set; } = false; public virtual DateTime ValidFromDate { get; set; } public virtual DateTime ValidToInclDate { get; set; } public virtual string DeactivationReason { get; set; }

What is the best way to extend the login validation to check if the user is active and if the current date is between the Valid From and Valid To dates when the user logs in. How do I customize the adduser to include the added fields when creating the user?

Answer

Angular

Question

I have added new setting definitions to my module public override void Define(ISettingDefinitionContext context) { /* Define module settings here. * Use names from AumSettings class. */ context.Add( new SettingDefinition(name : AumSettings.EmailRequired, defaultValue : "true", displayName : new LocalizableString( typeof(AumResource),"Setting:EmailRequired" ), description : new LocalizableString(typeof(AumResource), "Setting:EmailRequiredDescription"), isVisibleToClients : true ), new SettingDefinition(name: AumSettings.PhoneRequired, defaultValue: "false", displayName: new LocalizableString(typeof(AumResource), "Setting:PhoneRequired"), description: new LocalizableString(typeof(AumResource), "Setting:PhoneRequiredDescription"), isVisibleToClients: true ) );

    }
    

However these settings do not appear on the settings managment UI. What do I have to do to get these settings to be configurable on the settings page. the only settings visible are for the built in modules Identity management Lepton theme settings and Account

Question

We wish to support multiple databases, both oracle using the devart driver and SQL Server. The current depends on EntityFrameworkCoreModule depends on AbpEntityFrameworkCoreSqlServerModule. We wish to be able to switch between oracle and sql server using a configuration setting in the appsettings.json. 1. If we remove the AbpEntityFrameworkCoreSqlServerModule module and change the Configure<AbpDbContextOptions>(options => { options.UseSqlServer(); } to options.UseOracle(); will this just work. 2. Can we change this setting to if(dbType == "Oracle") { options.UseSqlServer(); } else { options.UseOracle(); } 3. The current geenrated EntityFrameworkCoreModule depends on AbpEntityFrameworkCoreSqlServerModule, If we do this and take out [DependsOn(typeof(AbpEntityFrameworkCoreSqlServerModule)] will sql server still work? if we leave it will oracle work? 4. I tried changing the table names to snake case, this worked for the migrations but at runtime the modules don't use the conversion. Is it possible to make the modules work with the snake case naming convension.

Question

Hi

  I've see a guide on how to create a new application and a new module.
  I have a created a new application for our solution.
   
  The entire solution and modules will be based on angular ui.
   
  I want to create a new module with a user interface,
  How do I create this module. 
            Will be a seperate solution?
            Is it possible to have the module in the solution as the base application visual studio solution?
            I would like to have a single visual studio solution if possible to develop the modules as well as the base application but keep the module code is seperate projects.
  How do I include this module in the application?
  How do I load the ui for the module in the main application.
  
  
  
  
Showing 21 to 26 of 26 entries
Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11