mirror of
https://github.com/balzack/databag.git
synced 2025-04-24 02:25:26 +00:00
cleanup on account remove
This commit is contained in:
parent
92eeaa4381
commit
0c73c3380e
@ -53,7 +53,6 @@ export interface Settings {
|
||||
unlockSeal(password: string): Promise<void>;
|
||||
updaterSeal(password: string): Promise<void>;
|
||||
forgetSeal(): Promise<void>;
|
||||
deleteAccount(): Promise<void>;
|
||||
|
||||
addConfigListener(ev: (config: Config) => void): void;
|
||||
removeConfigListener(ev: (config: Config) => void): void;
|
||||
|
@ -82,32 +82,27 @@ export class DatabagSDK {
|
||||
|
||||
public async remove(session: Session): Promise<void> {
|
||||
const sessionModule = session as SessionModule;
|
||||
const params = await sessionModule.close();
|
||||
const { node, secure, token } = sessionModule.getParams();
|
||||
await removeAccount(node, secure, token);
|
||||
await sessionModule.close();
|
||||
try {
|
||||
await this.store.clearLogin();
|
||||
}
|
||||
catch(err) {
|
||||
this.log.error(err);
|
||||
}
|
||||
try {
|
||||
const { node, secure, token } = params;
|
||||
await removeAccount(node, secure, token);
|
||||
}
|
||||
catch(err) {
|
||||
this.log.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async logout(session: Session, all: boolean): Promise<void> {
|
||||
const sessionModule = session as SessionModule;
|
||||
const params = await sessionModule.close();
|
||||
const { node, secure, token } = sessionModule.getParams();
|
||||
await sessionModule.close();
|
||||
try {
|
||||
await this.store.clearLogin();
|
||||
}
|
||||
catch(err) {
|
||||
this.log.error(err);
|
||||
}
|
||||
const { node, secure, token } = params;
|
||||
clearLogin(node, secure, token, all).then(() => {}).catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
|
@ -100,8 +100,13 @@ export class SessionModule implements Session {
|
||||
private getStatus(): string {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
public getParams(): { node: string, secure: boolean, token: string } {
|
||||
const { node, secure, token } = this;
|
||||
return { node, secure, token };
|
||||
}
|
||||
|
||||
public async close(): Promise<{ node: string, secure: boolean, token: string }> {
|
||||
public async close(): Promise<void> {
|
||||
await this.content.close();
|
||||
await this.attribute.close();
|
||||
await this.alias.close();
|
||||
@ -110,8 +115,6 @@ export class SessionModule implements Session {
|
||||
await this.settings.close();
|
||||
await this.stream.close();
|
||||
this.connection.close();
|
||||
const { node, secure, token } = this;
|
||||
return { node: node, secure: secure, token: token };
|
||||
}
|
||||
|
||||
public getSettings(): Settings {
|
||||
|
Loading…
x
Reference in New Issue
Block a user