module Handler.AccountLogout where

import Import

getAccountLogoutR :: Handler Html
getAccountLogoutR = do
  maybeUser <- lookupUser
  case maybeUser of
    Just user -> do
      deleteSession userIdentTxt
      deleteSession userLoginKeyTxt
      changeLoginKey user
      setMessage "All logged out"
      redirect HomeR
    Nothing -> permissionDenied "You aren't logged in."
