Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

get session

  • Loading branch information...
commit 5110add63c41dffb1ec7b794a6e2b6ed64cf7444 1 parent 54a8900
@pgte pgte authored
Showing with 28 additions and 0 deletions.
  1. +28 −0 nano.js
View
28 nano.js
@@ -366,6 +366,32 @@ module.exports = exports = nano = function database_module(cfg) {
}
/***************************************************************************
+ * session *
+ ***************************************************************************/
+ /*
+ * gets the current session if there us one
+ *
+ * e.g.
+ * nano.session(function (err, session) {
+ * if (err) {
+ * return console.log('oh noes!')
+ * }
+ *
+ * console.log('user is %s and has these roles: %j',
+ * session.userCtx.user, session.userCtx.roles);
+ *
+ * });
+ *
+ * @see relax
+ */
+ function session(callback) {
+ return relax(
+ { method : 'GET'
+ , db : '_session'
+ }, callback);
+ }
+
+ /***************************************************************************
* db *
***************************************************************************/
/*
@@ -1074,6 +1100,7 @@ module.exports = exports = nano = function database_module(cfg) {
return follow_db(db_name,params,cb);
}
, auth : auth_server // alias
+ , session : session
, insert : insert_doc
, get : get_doc
, head : head_doc
@@ -1129,6 +1156,7 @@ module.exports = exports = nano = function database_module(cfg) {
, relax : relax // alias
, dinosaur : relax // alias
, auth : auth_server
+ , session : session
};
// handle different type of configs
Please sign in to comment.
Something went wrong with that request. Please try again.