Open Closed

How to Customize Login and Register with DNTCaptcha.Core #1740


User avatar
0
piseth created
  • ABP Framework version: v4.4
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes / no
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

Hello

I want to have DNTCaptcha.Core to work with my application, because I want to use it in my intranet without having Internet connection. reCaptcha requires Internet connection.

Please help me


7 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    See https://support.abp.io/QA/Questions/160/How-to-customize-an-ABP-project

  • User Avatar
    0
    piseth created

    hi

    See https://support.abp.io/QA/Questions/160/How-to-customize-an-ABP-project

    Thank you very much. Let me try first

  • User Avatar
    0
    piseth created

    @maliming

    In order to make it not showing errors with LoginModel and Volo.Abp.Account.Web.AbpAccountOptions, I have to add Volo.Abp.Account.Web or Volo.Abp.Account.Web.IdentityServer

    public class CustomLoginModel : LoginModel { public CustomLoginModel( Microsoft.AspNetCore.Authentication.IAuthenticationSchemeProvider schemeProvider, IOptions<Volo.Abp.Account.Web.AbpAccountOptions> accountOptions, IOptions<IdentityOptions> identityOptions) : base(schemeProvider: schemeProvider, accountOptions: accountOptions, identityOptions: identityOptions) { } }

    However, i cannot start my web application at all. The program '[4741] Asiacell.Web.dll' has exited with code 0 (0x0).

  • User Avatar
    0
    piseth created

    hi

    See https://support.abp.io/QA/Questions/160/How-to-customize-an-ABP-project

    Here is the error:

    [13:17:05 FTL] Host terminated unexpectedly! Volo.Abp.AbpInitializationException: An error occurred during ConfigureServices phase of the module Volo.Abp.AspNetCore.Mvc.AbpAspNetCoreMvcModule, Volo.Abp.AspNetCore.Mvc, Version=4.4.0.0, Culture=neutral, PublicKeyToken=null. See the inner exception for details. ---> System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Could not load type 'Volo.Abp.Domain.Entities.IHasConcurrencyStamp' from assembly 'Volo.Abp.Ddd.Domain, Version=4.4.0.0, Culture=neutral, PublicKeyToken=null'. at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module) at System.Reflection.RuntimeAssembly.get_DefinedTypes() at Microsoft.AspNetCore.Mvc.ApplicationParts.AssemblyPart.get_Types() at Microsoft.AspNetCore.Mvc.Controllers.ControllerFeatureProvider.PopulateFeature(IEnumerable1 parts, ControllerFeature feature) at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateFeature[TFeature](TFeature feature) at Microsoft.Extensions.DependencyInjection.MvcCoreMvcBuilderExtensions.AddControllersAsServices(IMvcBuilder builder) at Volo.Abp.AspNetCore.Mvc.AbpAspNetCoreMvcModule.ConfigureServices(ServiceConfigurationContext context) at Volo.Abp.AbpApplicationBase.ConfigureServices() System.TypeLoadException: Could not load type 'Volo.Abp.Domain.Entities.IHasConcurrencyStamp' from assembly 'Volo.Abp.Ddd.Domain, Version=4.4.0.0, Culture=neutral, PublicKeyToken=null'. --- End of inner exception stack trace --- at Volo.Abp.AbpApplicationBase.ConfigureServices() at Volo.Abp.AbpApplicationBase..ctor(Type startupModuleType, IServiceCollection services, Action1 optionsAction) at Volo.Abp.AbpApplicationWithExternalServiceProvider..ctor(Type startupModuleType, IServiceCollection services, Action1 optionsAction) at Volo.Abp.AbpApplicationFactory.Create(Type startupModuleType, IServiceCollection services, Action1 optionsAction) at Volo.Abp.AbpApplicationFactory.Create[TStartupModule](IServiceCollection services, Action1 optionsAction) at Microsoft.Extensions.DependencyInjection.ServiceCollectionApplicationExtensions.AddApplication[TStartupModule](IServiceCollection services, Action1 optionsAction) at Asiacell.Web.Startup.ConfigureServices(IServiceCollection services) in /Users/pisethsan/Documents/projects/Test/qoe/src/Test.Web/Startup.cs:line 11 at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services) at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass9_0.<Invoke>g__Startup|0(IServiceCollection serviceCollection) at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection services) at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass8_0.<Build>b__0(IServiceCollection services) at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.UseStartup(Type startupType, HostBuilderContext context, IServiceCollection services, Object instance) at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass13_0.<UseStartup>b__0(HostBuilderContext context, IServiceCollection services) at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider() at Microsoft.Extensions.Hosting.HostBuilder.Build() at Test.Web.Program.Main(String[] args) in /Users/pisethsan/Documents/projects/Test/qoe/src/Test.Web/Program.cs:line 31

  • User Avatar
    0
    piseth created

    So i removed Volo.Abp.Account.Web or Volo.Abp.Account.Web.IdentityServer

    And I use "using Volo.Abp.Account.Public.Web.Pages.Account;", it doesnot show errors with LoginModel and AbpAccountOptions But it shows error:

    There is no argument given that corresponds to the required formal parameter 'recaptchaValidatorFactory' of 'LoginModel.LoginModel(IAuthenticationSchemeProvider, IOptions<AbpAccountOptions>, IAbpRecaptchaValidatorFactory, IAccountExternalProviderAppService, ICurrentPrincipalAccessor, IOptions<IdentityOptions>, IOptionsSnapshot<reCAPTCHAOptions>)'

  • User Avatar
    0
    piseth created

    So i removed Volo.Abp.Account.Web or Volo.Abp.Account.Web.IdentityServer

    And I use "using Volo.Abp.Account.Public.Web.Pages.Account;", it doesnot show errors with LoginModel and AbpAccountOptions But it shows error:

    There is no argument given that corresponds to the required formal parameter 'recaptchaValidatorFactory' of 'LoginModel.LoginModel(IAuthenticationSchemeProvider, IOptions<AbpAccountOptions>, IAbpRecaptchaValidatorFactory, IAccountExternalProviderAppService, ICurrentPrincipalAccessor, IOptions<IdentityOptions>, IOptionsSnapshot<reCAPTCHAOptions>)'

    I can solve the above problem.

    However i get the problem of getting Image from DNTCaptcha which it shows error: ComponentNotRegisteredException: The requested service 'DNTCaptcha.Core.DNTCaptchaImageController' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.

    Please kindly help me. I do the following for integrating with DNTCaptcha:

    1/ I install DNTCaptcha.Core (from Nuget) inside my project Web (Test.Web) 2/ I add this line @addTagHelper *, DNTCaptcha.Core inside _ViewImports.cshtml under Test.Web.Pages 3/ I add the following code inside TestWebModule.cs: context.Services.AddDNTCaptcha(options => options.UseCookieStorageProvider() .ShowThousandsSeparators(false) .WithEncryptionKey("This is my secure key!") ); 4/ I add the following code inside Login.cshtml under Pages/Account in Test.Web

    <div class="form-group"> <dnt-captcha asp-captcha-generator-max="999999" asp-captcha-generator-min="111111" asp-captcha-generator-language="English" asp-captcha-generator-display-mode="ShowDigits" asp-use-relative-urls="true" asp-placeholder="Enter Security code" asp-validation-error-message="Please enter the security code." asp-font-name="Tahoma" asp-font-size="20" asp-fore-color="#333333" asp-back-color="#ccc" asp-text-box-class="text-box form-control" asp-text-box-template="<span class='input-group-prepend'><span class='form-group-text'></span></span>{0}" asp-validation-message-class="text-danger" asp-refresh-button-class="fas fa-redo btn-sm" /> </div>

    5/ I can see the Captcha doesnot show Image. Please see the following:

  • User Avatar
    0
    piseth created

    So i removed Volo.Abp.Account.Web or Volo.Abp.Account.Web.IdentityServer

    And I use "using Volo.Abp.Account.Public.Web.Pages.Account;", it doesnot show errors with LoginModel and AbpAccountOptions
    But it shows error:

    There is no argument given that corresponds to the required formal parameter 'recaptchaValidatorFactory' of 'LoginModel.LoginModel(IAuthenticationSchemeProvider, IOptions<AbpAccountOptions>, IAbpRecaptchaValidatorFactory, IAccountExternalProviderAppService, ICurrentPrincipalAccessor, IOptions<IdentityOptions>, IOptionsSnapshot<reCAPTCHAOptions>)'

    I can solve the above problem.

    However i get the problem of getting Image from DNTCaptcha which it shows error: ComponentNotRegisteredException: The requested service 'DNTCaptcha.Core.DNTCaptchaImageController' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.

    Please kindly help me. I do the following for integrating with DNTCaptcha:

    1/ I install DNTCaptcha.Core (from Nuget) inside my project Web (Test.Web) 2/ I add this line @addTagHelper *, DNTCaptcha.Core inside _ViewImports.cshtml under Test.Web.Pages 3/ I add the following code inside TestWebModule.cs: context.Services.AddDNTCaptcha(options => options.UseCookieStorageProvider() .ShowThousandsSeparators(false) .WithEncryptionKey("This is my secure key!") ); 4/ I add the following code inside Login.cshtml under Pages/Account in Test.Web

    <div class="form-group"> <dnt-captcha asp-captcha-generator-max="999999" > asp-captcha-generator-min="111111" asp-captcha-generator-language="English" asp-captcha-generator-display-mode="ShowDigits" asp-use-relative-urls="true" asp-placeholder="Enter Security code" asp-validation-error-message="Please enter the security code." asp-font-name="Tahoma" asp-font-size="20" asp-fore-color="#333333" asp-back-color="#ccc" asp-text-box-class="text-box form-control" asp-text-box-template="<span class='input-group-prepend'><span class='form-group-text'></span></span>{0}" asp-validation-message-class="text-danger" asp-refresh-button-class="fas fa-redo btn-sm" /> </div>

    5/ I can see the Captcha doesnot show Image. Please see the following:

    I follow this link and i can solve this problem https://github.com/aspnetboilerplate/aspnetboilerplate/issues/6031

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11