Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to logout authenticated user in ServiceStack?

Tags:

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 ?

like image 682
Ameer Deen Avatar asked Jan 02 '13 04:01

Ameer Deen


2 Answers

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" });
like image 187
mythz Avatar answered Nov 05 '22 23:11

mythz


On ServiceStack v4 you will need this line instead.

client.Post(new Authenticate { provider = AuthenticateService.LogoutAction });
like image 26
labilbe Avatar answered Nov 05 '22 23:11

labilbe