We are using the microservice architecture and need to support a different post logout redirect uri depending on a certain condition e.g. (old customer go to X url).
Currently the post logout goes to the home page (no settings have changed) but as our home page requires authentication you get redirected to the login screen.
How do I make it so I can redirect the user to a different url? I have tried specifying the return url in the logoutasync method within the account controller but that is ignored.
ABP 9.3.1 OpenIddict
5 Answer(s)
-
0
hi
I have tried specifying the return url in the logoutasync method within the account controller but that is ignored.
Can you share your logout method code?
Thanks.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
public class AccountController(ILegacyTenantAppService legacyTenantAppService) : AbpAccountImpersonationChallengeAccountController { public override async Task<ActionResult> LogoutAsync(string returnUrl = "", string returnUrlHash = "") { var tenant = await legacyTenantAppService.GetLegacyIdAsync(); if (returnUrl.IsNullOrEmpty() &&tenant.LegacyId > 0) { returnUrl = $"https://domain.com/login/{tenant.LegacyId}?logout=1"; } return await base.LogoutAsync(returnUrl, returnUrlHash); } }Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
hi
The base class will call the
GetRedirectUrlAsync.Can you debug to check if your
returnUrlis set correctly?Thanks.
[HttpGet] public virtual async Task<ActionResult> LogoutAsync(string returnUrl = "", string returnUrlHash = "") { await HttpContext.SignOutAsync(); if (HttpContext.User.Identity?.AuthenticationType == AuthenticationType) { return await RedirectSafelyAsync(returnUrl, returnUrlHash); } return SignOut(new AuthenticationProperties { RedirectUri = await GetRedirectUrlAsync(returnUrl, returnUrlHash) }, ChallengeAuthenticationSchemas); }Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Looks like even though the return url is being passed in it then checks against options to allowed urls.
As this isn't a local url and is unique to each tenant I have made a new local url that redirects after the fact.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)