Provide us with the following info:
- ABP Framework version:v7.3.2
- UI Type: Angular
- Database System: EF Core (MySQL)
- Tiered (for MVC) or Auth Server Separated (for Angular): yes
- Exception message and full stack trace:
- Steps to reproduce the issue:
The problem is while using forgot password the link to reset the password for tenant user its not working its throwing 404 page not found error For the host its picking up the correct url and the correct page is getting displayed but the same is not working with the tenant url (subdomain) .Using reset password for tenant still reflects the host url with the correct tenantId. We have added the methods to reset password in the account module controller also included the pages after that still getting 400 error mentioned below. Here is the TenantDomainResolver we are using in the Auth server.
public class TenantDomainResolver : TenantResolveContributorBase
{
public const string ContributorName = "Custom";
public override string Name => ContributorName;
private static readonly string[] ProtocolPrefixes = { "http://", "https://" };
private readonly string DomainFormat;
private readonly string Environment;
public TenantDomainResolver(string domainFormat, string environment)
{
DomainFormat = domainFormat;
Environment = environment;
}
public override async Task ResolveAsync(ITenantResolveContext context)
{
var httpContext = context.GetHttpContext();
var referer = httpContext.Request.Headers["Referer"].ToString();
if (string.IsNullOrEmpty(referer))
{
return;
}
referer = referer.RemovePreFix(ProtocolPrefixes);
var extractResult = FormattedStringValueExtracter.Extract(referer, DomainFormat, ignoreCase: true);
if (extractResult != null && extractResult.IsMatch)
{
string subdomain = extractResult.Matches[0].Value;
if (subdomain != Environment)
{
if (Environment.IsNullOrEmpty() || subdomain.EndsWith(Environment))
{
context.Handled = true;
int lastIndex = subdomain.LastIndexOf(Environment);
context.TenantIdOrName = subdomain.Substring(0, lastIndex);
}
}
}
}
}
13 Answer(s)
-
0
-
0
I have updated the Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonX version to 2.3.2 from version 2.3.0 .But still facing the same error . As we are using custom URL for host and tenant. The URL sent in the forgot password email for the tenant should consists tenant name but its still sending the token with host URL only and as the correct url is not formed we are getting page not found error.
-
0
-
0
After updating the selfurl in appsettings for the auth server this error is occuring
The Url its redirecting to :- https://u38833538.ct.sendgrid.net/ls/click?upn=u001.NZdfXgy-2BdlZgtVTSnbOFdPeF8pPOS-2ByrIGdO8w9096fVPpIH-2BmsbBk89Z3AF-2FlFR4rW-2BaisuIfmIG5yI2uL-2FQ9Kr3WiOYkDp57v-2BVigSWpBrptxSt7w3EnL607FJaxbMC3CEvI2WmipmhK-2FJspEuclhc4k2T0WwUl7f4S-2FwTm51b55e1fYc8RsyiqZMD2I-2B8yKn3b06W5m9BRLEECRtsG3AHJ0Nw5RiOCIqZRqxDrKJZ3koTJQnDyx7S0A7fhcU6Ix-2FWI-2B3DhbSQ9fb51zzHzfka-2BEc-2FeS2FtPUlcrCQiD0dIC98IIZzkLhYj68NYR4MGIcauDN3pTvaTh-2BIEf-2FcSAg8vCKEcyBgk0FTZD-2B52SJK4yzMYSTR7JgtvnrjAa8qUJrcMAr-2FBasfXXEClTCBi27XUdlT4Rs9RyduWy9jsKYA-2BIC5l5g3DLdJztAbss6eBIQb-2FRnbAeyIgQqVd1f8hmNHM0Gp3QZjvOljXhmdEfOXRWKSqMgFivxyiSaZQDVvUSr9GhudgAIvJ5zv0NL-2FFWXWVZ6rmnDokk5Va8aLle0-3DRE27_fcdpf20PqIaxfNdR4zJ5gGbtNY-2BFgzJ7pdk6Geo3OtynZlj4s1vrmOzMLx5dHZhFnQBaife9AKjsHE3oN8nTyH-2B69JNPmiVcCafJ0jm3yaQ3StDyXuuNcyXpJgIQT41ZYLAWzWh1neVDYB218RmfZQWh2MKREp9XXOjViQUTpDk0r8fIdkW45fqAIitXf57-2BgXyYUToKFBb-2FusF7296hPg-3D-3D
-
0
https://u38833538.ct.sendgrid.net
The link is not your application URL, right. I don't know how it happened, Could you share some screenshots or a video?
https://support.abp.io/QA/Questions/7385/404-Error-using-Reset-Password-for-Tenant-users#answer-3a135a61-76ab-4e5c-7873-d204cc4b4364
And here are the steps I tried to reproduce
-
0
-
0
Hi,
You can try overriding the
AccountEmailer
to log the email content and check it.[Dependency(ReplaceServices = true)] [ExposeServices(typeof(AccountEmailer))] public class MyAccountEmailer : AccountEmailer { public ILogger<AccountEmailer> Logger { get; set; } public MyAccountEmailer(IEmailSender emailSender, ITemplateRenderer templateRenderer, IStringLocalizer<AccountResource> stringLocalizer, IAppUrlProvider appUrlProvider, ICurrentTenant currentTenant) : base(emailSender, templateRenderer, stringLocalizer, appUrlProvider, currentTenant) { Logger = NullLogger<AccountEmailer>.Instance; } public override async Task SendPasswordResetLinkAsync(IdentityUser user, string resetToken, string appName, string returnUrl = null, string returnUrlHash = null) { Debug.Assert(CurrentTenant.Id == user.TenantId, "This method can only work for current tenant!"); var url = await AppUrlProvider.GetResetPasswordUrlAsync(appName); //TODO: Use AbpAspNetCoreMultiTenancyOptions to get the key var link = $"{url}?userId={user.Id}&{TenantResolverConsts.DefaultTenantKey}={user.TenantId}&resetToken={UrlEncoder.Default.Encode(resetToken)}"; if (!returnUrl.IsNullOrEmpty()) { link += "&returnUrl=" + NormalizeReturnUrl(returnUrl); } if (!returnUrlHash.IsNullOrEmpty()) { link += "&returnUrlHash=" + returnUrlHash; } var emailContent = await TemplateRenderer.RenderAsync( AccountEmailTemplates.PasswordResetLink, new { link = link } ); Logger.LogInformation($"EmailContent: {emailContent}"); // logger here try { await EmailSender.QueueAsync( user.Email, StringLocalizer["PasswordReset"], emailContent ); } catch (Exception e) { Logger.LogException(e); throw new UserFriendlyException(StringLocalizer["MailSendingFailed"]); } } private string NormalizeReturnUrl(string returnUrl) { if (returnUrl.IsNullOrEmpty()) { return returnUrl; } //Handling openid connect login if (returnUrl.StartsWith("/connect/authorize/callback", StringComparison.OrdinalIgnoreCase)) { if (returnUrl.Contains("?")) { var queryPart = returnUrl.Split('?')[1]; var queryParameters = queryPart.Split('&'); foreach (var queryParameter in queryParameters) { if (queryParameter.Contains("=")) { var queryParam = queryParameter.Split('='); if (queryParam[0] == "redirect_uri") { return HttpUtility.UrlDecode(queryParam[1]); } } } } } if (returnUrl.StartsWith("/connect/authorize?", StringComparison.OrdinalIgnoreCase)) { return HttpUtility.UrlEncode(returnUrl); } return returnUrl; } }
-
0
While looking into this one more error I have found when we sent the verification email once the user register and when the user verify by clicking on the link received in the email it redirects to EmailConfirmation page with the host url but it should take the custom tenant url
-
0
Logger.LogInformation($"EmailContent: {emailContent}"); // logger here
What's the log content
-
0
An unhandled exception has occurred while executing the request. Volo.Abp.Domain.Entities.EntityNotFoundException: There is no such an entity. Entity type: Volo.Abp.Identity.IdentityUser, id: 3a134618-f70b-d756-7f15-74eb6cbde626 at Volo.Abp.Identity.IdentityUserManager.GetByIdAsync(Guid id)
Still getting this exception.
-
0
Could you share a simple example project that can reproduce the problem with me? I will check it. my email is shiwei.liang@volosoft.com
-
0
-
0
Hi,
Sorry, please try
{{tenantName}}
instead of{0}
https://github.com/abpframework/abp/blob/rel-7.3/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Urls/AppUrlProvider.cs#L16-L17C50
ABP support
{0}
from 8.0,I mixed them up. sorry.if still working could you share a simple example project that can reproduce the problem with me? I will check it. my email is shiwei.liang@volosoft.com