Ameer Deen
Ameer Deen

Reputation: 734

How to logout authenticated user in ServiceStack?

Apologize for the noob question. Just beginning to learn servicestack. I'm using a self-hosted console application with Razor for my view engine, the "RegistrationFeature" plugin for registrations and CredentialsAuthProvider for authentication via form post to allow users to login.

The SocialBootStrap application uses MVC 3 and does a "FormsAuthentication.SignOut()" to allow users to logout. Given that I'm using a self hosted application, I created a LogoutService that simply does a Request.RemoveSession() and that appears to work.

Is this the right way to log out a user's session ?

Upvotes: 14

Views: 4694

Answers (2)

mythz
mythz

Reputation: 143284

There is an explicit logout service i.e. /auth/logout as part of the ServiceStack's Authentication support that you should use instead.

You can do a GET or POST to /auth/logout or if you're using C# client you can logout with:

client.Post(new Authenticate { provider = "logout" });

Upvotes: 27

labilbe
labilbe

Reputation: 3574

On ServiceStack v4 you will need this line instead.

client.Post(new Authenticate { provider = AuthenticateService.LogoutAction });

Upvotes: 6

Related Questions