Skip to content

Commit 7f6a0b2

Browse files
authored
Support variable number of auth retry attempts through opt.retries (#1325)
Maintain default to 9 to ensure backwards compatibility
1 parent 0cb9706 commit 7f6a0b2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

sea.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,8 @@
968968
var pass = (alias || (pair && !(pair.priv && pair.epriv))) && typeof args[1] === 'string' ? args[1] : null;
969969
var cb = args.filter(arg => typeof arg === 'function')[0] || null; // cb now can stand anywhere, after alias/pass or pair
970970
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
971-
971+
var retries = typeof opt.retries === 'number' ? opt.retries : 9;
972+
972973
var gun = this, cat = (gun._), root = gun.back(-1);
973974

974975
if(cat.ing){
@@ -977,7 +978,7 @@
977978
}
978979
cat.ing = true;
979980

980-
var act = {}, u, tries = 9;
981+
var act = {}, u;
981982
act.a = function(data){
982983
if(!data){ return act.b() }
983984
if(!data.pub){
@@ -991,7 +992,7 @@
991992
var get = (act.list = (act.list||[]).concat(list||[])).shift();
992993
if(u === get){
993994
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.') }
994-
if(alias && tries--){
995+
if(alias && retries--){
995996
root.get('~@'+alias).once(act.a);
996997
return;
997998
}

0 commit comments

Comments
 (0)