Skip to content

Commit

Permalink
#36 storing token for subsequent uses
Browse files Browse the repository at this point in the history
  • Loading branch information
tracend committed Jan 12, 2013
1 parent a9617ef commit c0c9181
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ var crudr, socket;
auth : false,
deps: false,
socket: false
},
// defaults
options : {
log : false,
auth : true,
key : false,
secret : false
},
init : function(){

// defaults
this.options = {
log : false,
auth : true,
key : false,
secret : false
};
this.token = false;

this.promise = new Promise();
this.promise.add(function(){
Expand Down Expand Up @@ -59,11 +60,10 @@ var crudr, socket;
if( typeof callback != "undefined" ) {
this.promise.add( callback );
}
//var token = query("access_token");

// set auth state
if( typeof options.auth == "undefined" ) options.auth = true;


// If key is provided expect a valid confirmation from the callback
// unless auth=false, then the key is disegarded...
if( typeof options.key != "undefined" && options.auth ) {
Expand Down Expand Up @@ -92,8 +92,9 @@ var crudr, socket;

} else {
// continue with the cookie we already have...
//alert(cookie);

this.token = cookie;
this.status("authenticated");

}
} else {

Expand Down Expand Up @@ -214,6 +215,7 @@ var crudr, socket;
//
// save token in cookie...
Cookie.set("crudr_token", token, expiry);
this.token = token;
// in any case set the state of the object to:
this.status("authenticated");

Expand Down

0 comments on commit c0c9181

Please sign in to comment.