On Sun, Jan 20, 2013 at 12:13 PM, Zbigniew Łukasiak <zzb...@gmail.com> wrote: > I have not seen something like that in Clojure - so as my first coding > excercise in Clojure I've started porting my Perl library. > > https://github.com/zby/ring-form-authentication > > Quoting the README: > > It lets you quickly add to your application "/login" and "/logout" pages > pluss all the redirects and session management needed. > > It is a Ring based middleware. > > After the user has authenticated the session keeps his userid and the > application can check it for authorization: > (if (get (get request :session) :userid ) > > See example application in src/ring_form_authentication/example.clj > > This is very EXPERIMENTAL - it is my first code in Clojure. > > Any comments are welcome. I really just started learning Clojure and I have > not yet managed to read about all the language features. > > Cheers, > Zbigniew > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en
Looks like a good example as a middleware for protecting everything behind the page with a prebuilt form. Style wise, there are some nested `let`s and `or`s that could be collapsed. `use` is usually done with `:use` in the `ns` definition. Some functions that could be helpful include `if-let` and `get-in`. Usually middleware is written with the assumption that any required middleware has already been applied. This lets the user handle if they want any other middleware in between, or if the wrap-session/wrap-params should apply to the entire routing space, but the form authentication only to a subset. The use of `:session` in the response maps needs to copy over and alter the sessions from the request map. Otherwise it will lose session data from other middleware, or even the app. Have you seen friend and its interactive-form workflow? https://github.com/cemerick/friend/ -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en