Skip to content

Instantly share code, notes, and snippets.

@lsmag
Created March 2, 2017 01:17
Show Gist options
  • Save lsmag/6423b017e94750bc475468038c792e47 to your computer and use it in GitHub Desktop.
Save lsmag/6423b017e94750bc475468038c792e47 to your computer and use it in GitHub Desktop.
loginRequired = requireUser auth handleRedirect
where
-- this is the cleanest way (afaik) to write it
handleRedirect = withRequest (redirect . append "/login?to=" . rqURI)
-- that handleRedirect can be rewritten in a more imperative way:
handleRedirect = withRequest (\rq -> redirect (append "login?to=" (rqURI rq)))
-- or
handleRedirect = withRequest (\rq -> redirect . append "login?to=" . rqURI $ rq)
-- or?
handleRedirect = withRequest
(\rq ->
let uri = rqURI rq
loginRoute = append "login?to=" uri
in redirect loginRoute)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment