Permalink
Browse files

Support logging out if the token hasn't been fetched from the session…

… yet
  • Loading branch information...
1 parent 1ea4391 commit bc5d7685a00e7082953ff4faa24623037210dc69 @isaacs isaacs committed Apr 28, 2012
Showing with 8 additions and 0 deletions.
  1. +8 −0 couch-login.js
View
8 couch-login.js
@@ -128,6 +128,14 @@ function addToken (res) {
function logout (cb) {
+ if (!this.token && this.tokenGet) {
+ return this.tokenGet(function (er, tok) {
+ if (er || !tok) return cb()
+ this.token = tok
+ this.logout(cb)
+ }.bind(this))
+ }
+
if (!valid(this.token)) {
this.token = null
if (this.tokenDel) this.tokenDel()

0 comments on commit bc5d768

Please sign in to comment.