mirror of
https://github.com/amark/gun.git
synced 2025-06-06 14:16:44 +00:00
Support variable number of auth retry attempts through opt.retries (#1325)
Maintain default to 9 to ensure backwards compatibility
This commit is contained in:
parent
0cb9706393
commit
7f6a0b27c3
7
sea.js
7
sea.js
@ -968,7 +968,8 @@
|
|||||||
var pass = (alias || (pair && !(pair.priv && pair.epriv))) && typeof args[1] === 'string' ? args[1] : null;
|
var pass = (alias || (pair && !(pair.priv && pair.epriv))) && typeof args[1] === 'string' ? args[1] : null;
|
||||||
var cb = args.filter(arg => typeof arg === 'function')[0] || null; // cb now can stand anywhere, after alias/pass or pair
|
var cb = args.filter(arg => typeof arg === 'function')[0] || null; // cb now can stand anywhere, after alias/pass or pair
|
||||||
var opt = args && args.length > 1 && typeof args[args.length-1] === 'object' ? args[args.length-1] : {}; // opt is always the last parameter which typeof === 'object' and stands after cb
|
var opt = args && args.length > 1 && typeof args[args.length-1] === 'object' ? args[args.length-1] : {}; // opt is always the last parameter which typeof === 'object' and stands after cb
|
||||||
|
var retries = typeof opt.retries === 'number' ? opt.retries : 9;
|
||||||
|
|
||||||
var gun = this, cat = (gun._), root = gun.back(-1);
|
var gun = this, cat = (gun._), root = gun.back(-1);
|
||||||
|
|
||||||
if(cat.ing){
|
if(cat.ing){
|
||||||
@ -977,7 +978,7 @@
|
|||||||
}
|
}
|
||||||
cat.ing = true;
|
cat.ing = true;
|
||||||
|
|
||||||
var act = {}, u, tries = 9;
|
var act = {}, u;
|
||||||
act.a = function(data){
|
act.a = function(data){
|
||||||
if(!data){ return act.b() }
|
if(!data){ return act.b() }
|
||||||
if(!data.pub){
|
if(!data.pub){
|
||||||
@ -991,7 +992,7 @@
|
|||||||
var get = (act.list = (act.list||[]).concat(list||[])).shift();
|
var get = (act.list = (act.list||[]).concat(list||[])).shift();
|
||||||
if(u === get){
|
if(u === get){
|
||||||
if(act.name){ return act.err('Your user account is not published for dApps to access, please consider syncing it online, or allowing local access by adding your device as a peer.') }
|
if(act.name){ return act.err('Your user account is not published for dApps to access, please consider syncing it online, or allowing local access by adding your device as a peer.') }
|
||||||
if(alias && tries--){
|
if(alias && retries--){
|
||||||
root.get('~@'+alias).once(act.a);
|
root.get('~@'+alias).once(act.a);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user