Skip to content
Browse files

added 'revalidateAfter' to have a permanent login

  • Loading branch information...
1 parent d978ba6 commit 88151f5f448f315d240bf481c1e862d6696812bb @landeiro committed Aug 23, 2011
Showing with 12 additions and 1 deletion.
  1. +12 −1 lib/PJsonCouch.js
View
13 lib/PJsonCouch.js
@@ -201,7 +201,7 @@ var PJsonCouch = function (options) {
// initialise options defaults
options.headers = options.headers || {};
options.path = options.path || '';
-
+ var pjs = this;
if (this instanceof PJsonCouch) {
this.setDB = function (dbObj) {
@@ -223,6 +223,8 @@ var PJsonCouch = function (options) {
var myDB = options.db;
var mySession = "";
+ var myCredentials = {};
+
var config = {
debug: false,
@@ -245,6 +247,12 @@ var PJsonCouch = function (options) {
var postOptions = this.buildRequest("POST", {
serverAction: "_session"
});
+
+ if (credentials.revalidateAfter) {
+ var revalidateAfter = (credentials.revalidateAfter * 1000);
+ delete credentials.revalidateAfter;
+ setInterval(function() {pjs.login(credentials)}, revalidateAfter);
+ }
postOptions.headers = {};
postOptions.headers["Content-Type"] = "application/x-www-form-urlencoded";
// postOptions.headers["Referer"] = "http://127.0.0.1";
@@ -256,6 +264,9 @@ var PJsonCouch = function (options) {
mySession = cookie.split("=")[1].split(";")[0];
}
if (callBackFunction) {
+ if (revalidateAfter) {
+ res.revalidateAfter = revalidateAfter;
+ }
callBackFunction(res);
}
});

0 comments on commit 88151f5

Please sign in to comment.
Something went wrong with that request. Please try again.