Permalink
Browse files

added 'revalidateAfter' to have a permanent login

  • Loading branch information...
1 parent 88151f5 commit c9b9e2857759bf8769397b45c5c9ae237ea05003 @landeiro committed Aug 23, 2011
Showing with 5 additions and 2 deletions.
  1. +5 −2 lib/PJsonCouch.js
View
@@ -224,6 +224,7 @@ var PJsonCouch = function (options) {
var myDB = options.db;
var mySession = "";
var myCredentials = {};
+ var revalidateLoginTimer = "";
var config = {
@@ -251,11 +252,11 @@ var PJsonCouch = function (options) {
if (credentials.revalidateAfter) {
var revalidateAfter = (credentials.revalidateAfter * 1000);
delete credentials.revalidateAfter;
- setInterval(function() {pjs.login(credentials)}, revalidateAfter);
+ revalidateLoginTimer = 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";
var loginWith = "name=" + credentials.user + "&password=" + credentials.password;
postOptions.requireHeaders = true;
Utils.request(postOptions, loginWith, config, function (res) {
@@ -279,6 +280,8 @@ var PJsonCouch = function (options) {
Utils.request(reqOptions, "", config, function (logoutResult) {
if (logoutResult.ok) {
mySession = "";
+ if (revalidateLoginTimer !== "")
+ clearInterval(revalidateLoginTimer);
}
if (callBackFunction) {
callBackFunction(logoutResult);

0 comments on commit c9b9e28

Please sign in to comment.