mirror of
https://github.com/balzack/databag.git
synced 2025-04-23 01:55:17 +00:00
clearning session reference on logout
This commit is contained in:
parent
46e3f9eb4b
commit
1861f1acb2
@ -28,7 +28,7 @@ export interface Logging {
|
||||
}
|
||||
|
||||
export interface Session {
|
||||
close(): void;
|
||||
close(): { node: string, secure: boolean, token: string };
|
||||
|
||||
getAccount(): Account;
|
||||
getIdentity(): Identity;
|
||||
|
@ -4,6 +4,7 @@ import { BotModule } from './bot';
|
||||
import { ConsoleLogging } from './logging';
|
||||
import { type Store, OfflineStore, OnlineStore, NoStore } from './store';
|
||||
import { setLogin } from './net/setLogin';
|
||||
import { clearLogin } from './net/clearLogin';
|
||||
import { setAccess } from './net/setAccess';
|
||||
import { addAccount } from './net/addAccount';
|
||||
import { setAdmin } from './net/setAdmin';
|
||||
@ -64,8 +65,21 @@ export class DatabagSDK {
|
||||
return new SessionModule(this.store, this.crypto, this.log, appToken, node, secure, created);
|
||||
}
|
||||
|
||||
public async logout(session: Session): Promise<void> {
|
||||
session.close();
|
||||
public async logout(session: Session, all: boolean): Promise<void> {
|
||||
const params = session.close();
|
||||
try {
|
||||
const { node, secure, token } = params;
|
||||
await clearLogin(node, secure, token, all);
|
||||
}
|
||||
catch(err) {
|
||||
console.log(err);
|
||||
}
|
||||
try {
|
||||
await this.store.clearLogin();
|
||||
}
|
||||
catch(err) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async configure(node: string, secure: boolean, token: string, mfaCode: string | null): Promise<Node> {
|
||||
|
@ -131,7 +131,7 @@ export class SessionModule implements Session {
|
||||
}
|
||||
}
|
||||
|
||||
public close() {
|
||||
public close(): { node: string, secure: boolean, token: string } {
|
||||
this.connection.close();
|
||||
this.stream.close();
|
||||
this.content.close();
|
||||
@ -140,6 +140,7 @@ export class SessionModule implements Session {
|
||||
this.contact.close();
|
||||
this.identity.close();
|
||||
this.account.close();
|
||||
return { node: this.node, secure: this.secure, token: this.token };
|
||||
}
|
||||
|
||||
public getAccount(): Account {
|
||||
|
Loading…
x
Reference in New Issue
Block a user