Logout Web User
The logout event provides the functionality to logout users of your app. In this article we are going to show you how you can set up the logout event in 5 quick steps.
- Step 1. create a logout endpoint
- Step 2. create a logout action
- Step 3. add the logout event
- Step 4. build your code and test
Head over to the endpoint tab and create a new endpoint called "Logout user", with the path "/v1/logout_user", description "Logout users of my app" and the request method set to "Get". An example of this is shown below.
Save your endpoint and close it.
Next, from inside the actions tab, create an action called "Logout user" and associate the trigger component with the logout endpoint that we created in step 1.
Add the logout event to the "logout action" that we created in step 2. You can do this by clicking on the + Add Event button, as shown below.
Make sure that you save your action and close it.
The final step is to build your code and test it. To build your code click "Build code". Once the code has built, you can test it from inside the "Logout user" endpoint that we created in Step 1. Opening up the endpoint and clicking "Run" will allow you to test.
If your "Logout event" has run correctly, you'll see a Response Code 200.
To test this event more rigorously you can also follow the steps below.
- 2.Create some endpoints that require authentication.
- 4.Login a user and re-test the endpoints that require authentication. You should get a 200 success message, since the user is now logged in.
- 5.Create a logout event, as explained in this article.
- 6.Run your logout user endpoint again and re-test your endpoints that require authentication. You'll see these now return a 401 message, since the user is logged out..