anchor.diff:      _Else ->
           ?LOG_INFO("no record of user ~s", [UserName]),
           nil
  -    end,
  -    couch_db:close(Db),
  -    UserProps.
  +    catch error:database_does_not_exist ->
  +        nil
  +    end.
   
   ensure_users_db_exists(DbName) ->
  -    Options = [{user_ctx, #user_ctx{roles=[<<"_admin">>]}}],
  -    case couch_db:open(DbName, Options) of
  -    {ok, Db} ->
  -        {ok, Db};
  -    {error, _} -> 
  -        couch_db:create(DbName, Options)
  +    try fabric:get_doc_count(DbName) of
  +    {ok, N} when is_integer(N) ->
  +        ok;
  +    {error, _} ->
  +        fabric:create_db(DbName, [])
  +    catch error:database_does_not_exist ->
  +        fabric:create_db(DbName, [])
       end.
   
   % internal functions
  
positive.code:     end.
  
  load_user_from_db(UserName) ->
      DbName = couch_config:get("chttpd_auth", "authentication_db"),
      {ok, Db} = ensure_users_db_exists(?l2b(DbName)),
      UserProps = case couch_db:open_doc(Db, UserName, []) of
      {ok, Doc} ->
          ?LOG_INFO("cache miss on username ~s", [UserName]),
          {Props} = couch_doc:to_json_obj(Doc, []),
  
negative.code:                 {<<"username">>, UserName}
              ]}
          },
          {ok, _Rev} = fabric:update_doc(Db, UserDoc, []),
          ?LOG_DEBUG("User ~s (~s) with password, ~s created.", [UserName,
              UserName, Password]),
          send_response(Req);
  