This commit is contained in:
@@ -1,15 +1,20 @@
|
||||
import { StringSchemaDefinition } from 'mongoose';
|
||||
import { StringSchemaDefinition } from "mongoose";
|
||||
|
||||
import { Auth, Log, Strategy, Token } from '..';
|
||||
import { Status } from '../constants/auth';
|
||||
import { Action } from '../constants/action';
|
||||
import { Auth, Log, Strategy, Token } from "..";
|
||||
import { Status } from "../constants/auth";
|
||||
import { Action } from "../constants/action";
|
||||
|
||||
export const deleteById = async (id: StringSchemaDefinition) => {
|
||||
if (await Auth.findByIdAndUpdate(id, { status: Status.DELETED, strategies: [] }).catch()) {
|
||||
await Strategy.deleteMany({ parent: id });
|
||||
await Token.deleteMany({ auth: id });
|
||||
Log.add(id, Action.DELETE);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
if (
|
||||
await Auth.findByIdAndUpdate(id, {
|
||||
status: Status.DELETED,
|
||||
strategies: [],
|
||||
}).catch()
|
||||
) {
|
||||
await Strategy.deleteMany({ parent: id });
|
||||
await Token.deleteMany({ auth: id });
|
||||
Log.add(id, Action.DELETE);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user