Add orgId to reuse login1/login2 logic for LDAP 2nd step login

This commit is contained in:
Tuan Dang
2024-02-26 10:41:44 -08:00
parent 1c088b3a58
commit 9ba4b939a4
8 changed files with 40 additions and 10 deletions
+6 -2
View File
@@ -20,10 +20,14 @@ export const userDALFactory = (db: TDbClient) => {
// USER ENCRYPTION FUNCTIONS
// -------------------------
const findUserEncKeyByUsername = async (username: string) => {
const findUserEncKeyByUsername = async ({ username, orgId }: { username: string; orgId?: string }) => {
try {
return await db(TableName.Users)
.where({ username, isGhost: false })
.where({
username,
...(orgId ? { orgId } : { orgId: null }),
isGhost: false
})
.join(TableName.UserEncryptionKey, `${TableName.Users}.id`, `${TableName.UserEncryptionKey}.userId`)
.first();
} catch (error) {