Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[BUG] After explicit logout, hit on login, then it is automatically recognized instead of showing the login page #339

Closed
Cuiqs76 opened this issue Sep 19, 2017 · 8 comments
Assignees

Comments

@Cuiqs76
Copy link

Cuiqs76 commented Sep 19, 2017

wrong action logOff <form asp-area="" asp-controller="Account" asp-action="LogOff" method="post" id="logoutForm" class="navbar-right">
there is no corresponding action in the controller.

and I run the Identity.Api and logout throw a error from return Redirect(logout?.PostLogoutRedirectUri):

ArgumentException: Value cannot be null or empty.
Parameter name: url
Microsoft.AspNetCore.Mvc.ControllerBase.Redirect(string url)

@CESARDELATORRE
Copy link
Collaborator

What branch code are you using?
What environment?
I just tested the latest version in my machine and the login page in the MVC app is working properly for me.
Can you provide further context?
Thanks,

@Cuiqs76
Copy link
Author

Cuiqs76 commented Sep 19, 2017

I direct test url: localhost/5105/account/login throw error

KeyNotFoundException: The given key was not present in the dictionary.
System.ThrowHelper.ThrowKeyNotFoundException()
System.Collections.Generic.Dictionary.get_Item(TKey key)
IdentityServer4.Services.DefaultUserSession+d__16.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
IdentityServer4.Hosting.IdentityServerAuthenticationService+d__7.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Identity.SignInManager+d__30.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.eShopOnContainers.Services.Identity.API.Controllers.AccountController+d__7.MoveNext() in AccountController.cs
+
await _loginService.SignIn(user);
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
System.Runtime.CompilerServices.TaskAwaiter.GetResult()
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+d__12.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+d__10.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+d__14.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+d__22.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+d__17.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+d__15.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Builder.RouterMiddleware+d__4.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
IdentityServer4.Hosting.IdentityServerMiddleware+d__4.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Authentication.AuthenticationMiddleware+d__6.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware+d__7.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
IdentityServer4.Hosting.BaseUrlMiddleware+d__3.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Authentication.AuthenticationMiddleware+d__6.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.eShopOnContainers.Services.Identity.API.Startup+<>c+<b__5_0>d.MoveNext() in Startup.cs
+
await next();
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.MigrationsEndPointMiddleware+d__4.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware+d__6.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware+d__6.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware+d__7.MoveNext()

@Cuiqs76 Cuiqs76 closed this as completed Sep 20, 2017
@Cuiqs76
Copy link
Author

Cuiqs76 commented Sep 20, 2017

I test it in windows 10 with localdb, VS2017 . click login->logout->login. the login form no represent again.

@CESARDELATORRE
Copy link
Collaborator

CESARDELATORRE commented Sep 20, 2017

That is because the token is still valid and we login automatically with the older token, so it appears again logged with the original user.
But I think you are right, if you logout, it should force it and fully logout... Then,, when going to the login page you should see the edit boxes for the user/password, etc.
I'm creating a BUG with this issue.

@CESARDELATORRE CESARDELATORRE changed the title wrong asp-action in _LoginPartial.cshtml [BUG] After logout, hit on login, then it is automatically loging instead of showing the login page Sep 20, 2017
@CESARDELATORRE CESARDELATORRE changed the title [BUG] After logout, hit on login, then it is automatically loging instead of showing the login page [BUG] After explicit logout, hit on login, then it is automatically recognized instead of showing the login page Sep 20, 2017
@araselahi
Copy link

As mentioned in IdentityServer4 Sign-out Document:
you can use the convenience extension method that is provided by IdentityServer:
await HttpContext.SignOutAsync();
but it seems that it can not remove the mentioned cookie. Cookie name: .AspNetCore.Identity.Application

@araselahi
Copy link

araselahi commented Feb 27, 2018

// delete authentication cookie
await HttpContext.SignOutAsync();
Does not work. Does anybody know why?

Replace it with:
HttpContext.Response.Cookies.Delete(".AspNetCore.Identity.Application");
It should do the job!

@BrunoLopes
Copy link

Is this problem resolved?
Because I can make it works! And I think that the turn around solution is not a real option...

@TarasovN
Copy link

Asp.Net Identity + Identity server 4 uses a little bit different cookies. Try to use
await HttpContext.SignOutAsync("Identity.Application");

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants