Skip to content

Commit 3e7f57a

Browse files
committed
fix: do not overwrite hookKey when reinitializing with the same appId
1 parent 93f707e commit 3e7f57a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/init.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,16 @@ AV.init = function init(options, ...params) {
8787
);
8888
}
8989
}
90+
if (appId !== AV._config.applicationId) {
91+
// overwrite all keys when reinitializing as a new app
92+
AV._config.masterKey = masterKey;
93+
AV._config.hookKey = hookKey;
94+
} else {
95+
if (masterKey) AV._config.masterKey = masterKey;
96+
if (hookKey) AV._config.hookKey = hookKey;
97+
}
9098
AV._config.applicationId = appId;
9199
AV._config.applicationKey = appKey;
92-
AV._config.masterKey = masterKey;
93-
AV._config.hookKey = hookKey;
94100
AV.setProduction(production);
95101
if (typeof disableCurrentUser !== 'undefined')
96102
AV._config.disableCurrentUser = disableCurrentUser;

0 commit comments

Comments
 (0)