authentication - equivalent to global "before_filter" in Yesod -


i have been attempting play yesod, , have run simple problem can not seem find solution to.

say want have global function, runs on every request irrelevantly of route or handler (for example authentication function). want like

   uid <- requireauthid 

to run before every handler function , return control handler function when uid provided / if exists

where slot in? 'yesod way' of doing before filters?

one way modify yesod instance foundation type. assuming foundation type called app, can following force authorization before other handlers called.

instance yesod app --the following lines somewhere within block.     isauthorized (authr loginr) _ = return authorized     -- don't want accidentally lose access login page!     isauthorized _ _ =         mauth <- maybeauth         case mauth of              _ -> return authorized              nothing -> return $ unauthorized "you must login first." 

obviously, edit suit needs, should give idea of how this.


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -