Skip to content

Commit 4c18696

Browse files
committed
fix UtilData.createSession
1 parent 0641002 commit 4c18696

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

src/ts/lib/util/data.ts

+21-10
Original file line numberDiff line numberDiff line change
@@ -486,18 +486,29 @@ class UtilData {
486486
};
487487

488488
createSession (phrase: string, key: string, callBack?: (message: any) => void) {
489-
C.WalletCreateSession(phrase, key, (message: any) => {
489+
const { token } = S.Auth;
490+
const cb = () => {
491+
C.WalletCreateSession(phrase, key, (message: any) => {
492+
if (!message.error.code) {
493+
S.Auth.tokenSet(message.token);
494+
S.Auth.appTokenSet(message.appToken);
495+
dispatcher.listenEvents();
496+
};
490497

491-
if (!message.error.code) {
492-
S.Auth.tokenSet(message.token);
493-
S.Auth.appTokenSet(message.appToken);
494-
dispatcher.listenEvents();
495-
};
498+
if (callBack) {
499+
callBack(message);
500+
};
501+
});
502+
};
496503

497-
if (callBack) {
498-
callBack(message);
499-
};
500-
});
504+
if (token) {
505+
C.WalletCloseSession(token, () => {
506+
S.Auth.tokenSet('');
507+
cb();
508+
});
509+
} else {
510+
cb();
511+
};
501512
};
502513

503514
blockSetText (rootId: string, blockId: string, text: string, marks: I.Mark[], update: boolean, callBack?: (message: any) => void) {

0 commit comments

Comments
 (0)