Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

LogOut scaffolding (Razor Page) does not Redirect with Logout Id #2788

Closed
datvm opened this issue Nov 10, 2018 · 3 comments
Closed

LogOut scaffolding (Razor Page) does not Redirect with Logout Id #2788

datvm opened this issue Nov 10, 2018 · 3 comments
Labels

Comments

@datvm
Copy link

datvm commented Nov 10, 2018

The scaffolding of Logout file does not have any logic for redirecting called from Client. Therefore, I suggest a fix here (sorry I don't know where the scaffolding files are so I cannot make a pull request, please help): https://stackoverflow.com/questions/43259870/identityserver4-redirect-to-mvc-client-after-logout/53240640#53240640

Basically, add IIdentityServerInteractionService and add support for Logout Redirect logic:

        public async Task<IActionResult> OnGet(string returnUrl = null)
        {
            return await this.OnPost(returnUrl);
        }

        public async Task<IActionResult> OnPost(string returnUrl = null)
        {
            await _signInManager.SignOutAsync();
            _logger.LogInformation("User logged out.");

            var logoutId = this.Request.Query["logoutId"].ToString();

            if (returnUrl != null)
            {
                return LocalRedirect(returnUrl);
            }
            else if (!string.IsNullOrEmpty(logoutId))
            {
                var logoutContext = await this._interaction.GetLogoutContextAsync(logoutId);
                returnUrl = logoutContext.PostLogoutRedirectUri;

                if (!string.IsNullOrEmpty(returnUrl))
                {
                    return this.Redirect(returnUrl);
                }
                else
                {
                    return Page();
                }
            }
            else
            {
                return Page();
            }
        }

Current Default Scaffolding:

        public async Task<IActionResult> OnPost(string returnUrl = null)
        {
            await _signInManager.SignOutAsync();
            _logger.LogInformation("User logged out.");
            if (returnUrl != null)
            {
                return LocalRedirect(returnUrl);
            }
            else
            {
                return Page();
            }
        }
@brockallen
Copy link
Member

All of that code is from ASP.NET Identity, and not from any templates we provide. If you take someone else's templates then of course you will have to change them to work properly with the IdentityServer programming model.

So I don't think there's anything to do here.

@datvm
Copy link
Author

datvm commented Nov 10, 2018

Oh sorry I didn't notice that. My bad.

@datvm datvm closed this as completed Nov 10, 2018
@lock
Copy link

lock bot commented Jan 12, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants