Open Closed

Forgot Password functionality error #1525


User avatar
0
Repunjay created

ABP Framework version: v4.3.1 UI type: Angular DB provider: EF Core Tiered (MVC) or Identity Server Separated (Angular): yes

We have custom login page and using AWS SES for sending emails. Steps performed

  1. Code added in Login components <a href="/account/forgot-password" class="forgot_pass_cl"> {{ 'AbpAccount::ForgotPassword' | abpLocalization }}</a>

  2. When we click on Forgot Password? Its redirected to url http://localhost:4200/account/forgot-password

  3. We are entering aws certified email on submit its calling api https://localhost:44359/api/account/send-password-reset-code The response of api is Status Code: 403 Forbidden JSON Response {"error":{"code":null,"message":"Can not find the given email address:Ish***** **@****s.com","details":null,"data":{},"validationErrors":null}}

  4. Downloaded latest package Volo.Abp.Identity.AspNetCore package in Lit***.HttpApi project

  5. Define this package in the LitHttpApiModule class in the LitName.HttpApi project

  6. Added entry in Lit***.HttpApi.Host project appsettings.json "App": { "ClientUrl": "http://localhost:4200", }

  7. ConfigureUrls options.Applications["Angular"].RootUrl = configuration["App:ClientUrl"]; options.Applications["Angular"].Urls[AccountUrlNames.PasswordReset] = "account/reset-password"; options.Applications["Angular"].Urls[AccountUrlNames.EmailConfirmation] = "account/email-confirmation";

  8. Added ConfigureUrls To ConfigureServices() method in Lit***HttpApiHostModule class

Getting 403 Forbidden error, please advise.


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

    The response of api is Status Code: 403 Forbidden

    Can not find the given email address:Ish @s.com

    It will throw an UserFriendlyException exception when the GetUserByEmail method cannot find user, and its status code will be 403, which is by design.

    protected virtual async Task<IdentityUser> GetUserByEmail(string email)
    {
        var user = await UserManager.FindByEmailAsync(email);
        if (user == null)
        {
            throw new UserFriendlyException(L["Volo.Account:InvalidEmailAddress", email]);
        }
    
        return user;
    }
    

    https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/DefaultHttpExceptionStatusCodeFinder.cs#L72

  • User Avatar
    0
    Repunjay created

    The response of api is Status Code: 403 Forbidden

    Can not find the given email address:Ish @s.com

    It will throw an UserFriendlyException exception when the GetUserByEmail method cannot find user, and its status code will be 403, which is by design.

    protected virtual async Task<IdentityUser> GetUserByEmail(string email) 
    { 
        var user = await UserManager.FindByEmailAsync(email); 
        if (user == null) 
        { 
            throw new UserFriendlyException(L["Volo.Account:InvalidEmailAddress", email]); 
        } 
     
        return user; 
    } 
    

    https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/DefaultHttpExceptionStatusCodeFinder.cs#L72

    hi,

    Actually this is not the issue. We have enabled the Forgot Password flow into front-end and ABP uses SMTP for sending email notifications.

    For our project, we are using AWS SES service for sending email notification to users. All the example we have seen for forgot password are using SMTP methods. Will you please guide us how to utilize forgot password feature with AWS SES method?

    This is one important ask our product owner is looking and we would like to finish this feature ASAP. We will appreciate your quick response

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can implementation your own AWSSESEmailSender, Just like MailKitSmtpEmailSender .

    https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.MailKit/Volo/Abp/MailKit/MailKitSmtpEmailSender.cs#L15 https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.MailKit/Volo/Abp/MailKit/AbpMailKitModule.cs https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.MailKit/Volo/Abp/MailKit/IMailKitSmtpEmailSender.cs https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.MailKit/Volo/Abp/MailKit/AbpMailKitOptions.cs

  • User Avatar
    0
    Repunjay created

    hi

    You can implementation your own AWSSESEmailSender, Just like MailKitSmtpEmailSender .

    https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.MailKit/Volo/Abp/MailKit/MailKitSmtpEmailSender.cs#L15 https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.MailKit/Volo/Abp/MailKit/AbpMailKitModule.cs https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.MailKit/Volo/Abp/MailKit/IMailKitSmtpEmailSender.cs https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.MailKit/Volo/Abp/MailKit/AbpMailKitOptions.cs

    Hi,

    Please note we already have a SESEmailSender class in our project which is used to send out email notifications thru AWS SES. We want to understand how to invoke/integrate email send method of this class when password is reset by clicking "Forgot Password" ? In the interest of time, can we have a quick call remotely to understand and resolve this issue?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Is your SESEmailSender implement the IEmailSender and replace default one in the DI?

    Account Pro will use IEmailSender to send emails by default.

    https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/IEmailSender.cs#L9

  • User Avatar
    0
    ServiceBot created
    Support Team Automatic process manager

    This question has been automatically marked as stale because it has not had recent activity.

  • User Avatar
    0
    balessi75 created

    hi

    Is your SESEmailSender implement the IEmailSender and replace default one in the DI?

    Account Pro will use IEmailSender to send emails by default.

    https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/IEmailSender.cs#L9

    When creating a custom email sender (SESEmailSender in this case) that implements IEmailSender, how does one have Account Pro register the custom email sender to the DI?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        context.Services.Replace(ServiceDescriptor.Singleton<IEmailSender, SESEmailSender>());
    }
    
Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11