mirror of
https://github.com/balzack/databag.git
synced 2025-05-04 15:35:16 +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>;
|
unlockSeal(password: string): Promise<void>;
|
||||||
updaterSeal(password: string): Promise<void>;
|
updaterSeal(password: string): Promise<void>;
|
||||||
forgetSeal(): Promise<void>;
|
forgetSeal(): Promise<void>;
|
||||||
deleteAccount(): Promise<void>;
|
|
||||||
|
|
||||||
addConfigListener(ev: (config: Config) => void): void;
|
addConfigListener(ev: (config: Config) => void): void;
|
||||||
removeConfigListener(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> {
|
public async remove(session: Session): Promise<void> {
|
||||||
const sessionModule = session as SessionModule;
|
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 {
|
try {
|
||||||
await this.store.clearLogin();
|
await this.store.clearLogin();
|
||||||
}
|
}
|
||||||
catch(err) {
|
catch(err) {
|
||||||
this.log.error(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> {
|
public async logout(session: Session, all: boolean): Promise<void> {
|
||||||
const sessionModule = session as SessionModule;
|
const sessionModule = session as SessionModule;
|
||||||
const params = await sessionModule.close();
|
const { node, secure, token } = sessionModule.getParams();
|
||||||
|
await sessionModule.close();
|
||||||
try {
|
try {
|
||||||
await this.store.clearLogin();
|
await this.store.clearLogin();
|
||||||
}
|
}
|
||||||
catch(err) {
|
catch(err) {
|
||||||
this.log.error(err);
|
this.log.error(err);
|
||||||
}
|
}
|
||||||
const { node, secure, token } = params;
|
|
||||||
clearLogin(node, secure, token, all).then(() => {}).catch(err => {
|
clearLogin(node, secure, token, all).then(() => {}).catch(err => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
});
|
});
|
||||||
|
@ -101,7 +101,12 @@ export class SessionModule implements Session {
|
|||||||
return this.status;
|
return this.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async close(): Promise<{ node: string, secure: boolean, token: string }> {
|
public getParams(): { node: string, secure: boolean, token: string } {
|
||||||
|
const { node, secure, token } = this;
|
||||||
|
return { node, secure, token };
|
||||||
|
}
|
||||||
|
|
||||||
|
public async close(): Promise<void> {
|
||||||
await this.content.close();
|
await this.content.close();
|
||||||
await this.attribute.close();
|
await this.attribute.close();
|
||||||
await this.alias.close();
|
await this.alias.close();
|
||||||
@ -110,8 +115,6 @@ export class SessionModule implements Session {
|
|||||||
await this.settings.close();
|
await this.settings.close();
|
||||||
await this.stream.close();
|
await this.stream.close();
|
||||||
this.connection.close();
|
this.connection.close();
|
||||||
const { node, secure, token } = this;
|
|
||||||
return { node: node, secure: secure, token: token };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public getSettings(): Settings {
|
public getSettings(): Settings {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user