gun/sea/recall.js
2021-08-21 21:27:00 -07:00

27 lines
839 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;
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;
}