Created account.ts#getSimpleAccountObjectById

This commit is contained in:
Mathias Wagner 2023-01-22 19:49:27 +01:00
parent a45b419e9c
commit c330d78fb3
Signed by: Mathias
GPG Key ID: B8DC354B0A1F5B44

View File

@ -59,4 +59,13 @@ export const updateTOTP = async (id: ObjectId | undefined, status: boolean) => {
}; };
await Account.findByIdAndUpdate(id, { totpEnabled: status }); await Account.findByIdAndUpdate(id, { totpEnabled: status });
}; };
export const getSimpleAccountObjectById = async (id: string) => {
if (!Types.ObjectId.isValid(id)) return { code: 3, message: "Invalid object id provided" };
const account = await Account.findById(id);
if (account === null) return {};
return {id: account._id, username: account.username, email: account.email};
}