-USING: accessors assocs couchdb furnace.auth.providers
-json.writer kernel mirrors sequences urls urls.encoding
-arrays furnace.auth byte-arrays combinators.short-circuit
-strings continuations combinators base64 make
-locals namespaces ;
+USING: accessors assocs base64 byte-arrays combinators.short-circuit
+continuations couchdb fry furnace.auth.providers json.writer kernel
+locals make mirrors namespaces sequences strings urls urls.encoding ;
IN: furnace.auth.providers.couchdb
! !!! Implement the authentication protocol for CouchDB.
prefix>> [ % url-encode-full % "!" % url-encode-full % ] "" make ;
: (reserve) ( value name -- id/f )
- reservation-id
- get-url
- [
- H{ } clone >json swap couch-put
- ] [
- nip dup is-couchdb-conflict-error? [ drop f ] [ rethrow ] if
- ] recover ;
+ '[
+ _ _ reservation-id get-url
+ H{ } clone swap couch-put
+ ] [ is-couchdb-conflict-error? ] ignore-error/f ;
! Don't reserve false values (e.g. if the email field is f, don't reserve f,
! or the first user who registers without an email address will block all
couch-delete drop ;
: unreserve-from-id ( id -- )
- [
- get-url dup couch-get
+ '[
+ _ get-url dup couch-get
"_rev" of "rev" set-query-param
couch-delete drop
- ] [
- dup is-couchdb-not-found-error? [ 2drop ] [ rethrow ] if
- ] recover ;
+ ] [ is-couchdb-not-found-error? ] ignore-error ;
:: (reserve-multiple) ( hash keys made -- ? )
keys empty? [ t ] [