Search code examples
haskellyesodhamlet

How do I access a user's authentication from a hamlet template?


For example, If a nobody is logged in, I want to show them links to where they can sign up or log back in, but if a user is logged in, I want a way to let them access their profile and other information.


Solution

  • You need to use maybeAuth from the Haskell code to get the auth information, then $maybe inside Hamlet to change behavior based on that result. You can't do maybeAuth from inside Hamlet, since Hamlet does not allow you to perform any actions (like database lookups).