Base solution for your next web application
Open Closed

Forget Password when using 'Sign in Without Specifying Tenant' #10758


User avatar
0
rvanwoezik created

ASP.NET CORE & Angular (single solution) .NET 5.0 v10.2.0

Hi, i have incorporate 'Forget Password when using 'Sign in Without Specifying Tenant'

But when users use the option "Forgot Password" and enter their email they get the message "Invalid email"

Please Advice, Kind regards, Rene van Woezik


3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @rvanwoezik

    You need to implement determination of the tenant for the forgot password functionality as you do for login operation. Sorry that this is not explained in the article.

  • User Avatar
    0
    rvanwoezik created

    ~~Can you please guid me in the right direction?~~

    Found it, i have added the following to UserManager

    public async Task<User> TryGetUserWithoutSpecifyingTenant(string userEmail)
            {
                using (_unitOfWorkManager.Current.DisableFilter(AbpDataFilters.MayHaveTenant))
                {
                    var user = await Users.SingleOrDefaultAsync(u => u.EmailAddress == userEmail.Trim());
                    if (user == null)
                    {
                        throw new Exception("There is no user with email: " + userEmail);
                    }
    
                    return user;
                    
                }
            }
    

    And in the AccountAppService

    private async Task<User> GetUserByChecking(string inputEmailAddress)
            {
                var user = await UserManager.TryGetUserWithoutSpecifyingTenant(inputEmailAddress);
                if (user == null)
                {
                    throw new UserFriendlyException(L("InvalidEmailAddress"));
                }
    
                return user;
            }
    

    If there is a better way please let me know.

    Kind regards, Rene van Woezik

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @rvanwoezik

    Yes, this is the best way.