Subscription required

We're contionusly adding new episodes to IHP Casts. Continue your journey into real-world functional programming by subscribing to IHP Casts!

Watch all of IHP Casts for 10 € / Mo

IHP Casts is made by digitally induced, the company making IHP. By using a paid plan you're supporting our mission to drive the adoption of haskell in the software industry.

Episode completed

Next epsiode starting in 3 seconds

Published at

Script

Logging a user out is just a matter of deleting their session. To do that, we just need to place a Button pointing to the DeleteSessionAction when the user is logged in. To check the session we need to import the View Helper from our Application. We can use the Login Button from our navigation bar and instead display a logout button when the user is already logged in. To do that, we can use currentUserOrNothing to check if the user is logged in for the conditional displaying of the Buttons. The Logout button also needs the js-delete and js-delete-no-confirm classes, since we are sending a delete request but we don’t want to have the user confirm the logout. Now, our navbar displays a login button when no user is logged in and a logout button when there is a user logged in.

Discussion