mirror of
https://github.com/amark/gun.git
synced 2025-05-31 19:26:42 +00:00
27 lines
874 B
JavaScript
27 lines
874 B
JavaScript
|
|
var User = require('./user'), SEA = User.SEA, Gun = User.GUN;
|
|
User.prototype.recall = function(opt, cb){
|
|
var gun = this, root = gun.back(-1), tmp;
|
|
opt = opt || {};
|
|
if(opt && opt.sessionStorage){
|
|
if(SEA.window){
|
|
try{
|
|
var sS = {};
|
|
sS = window.sessionStorage; // TODO: FIX BUG putting on `.is`!
|
|
if(sS){
|
|
(root._).opt.remember = true;
|
|
((gun.back('user')._).opt||opt).remember = true;
|
|
if(sS.recall || sS.pair) root.user().auth(JSON.parse(sS.pair), cb); // pair is more reliable than alias/pass
|
|
}
|
|
}catch(e){}
|
|
}
|
|
return gun;
|
|
}
|
|
/*
|
|
TODO: copy mhelander's expiry code back in.
|
|
Although, we should check with community,
|
|
should expiry be core or a plugin?
|
|
*/
|
|
return gun;
|
|
}
|
|
|