1
0
Fork 0
mirror of synced 2024-09-17 17:57:47 +12:00
budibase/packages/backend-core/src/users.js

22 lines
587 B
JavaScript
Raw Normal View History

2022-04-08 12:28:22 +12:00
const { ViewNames } = require("./db/utils")
const { queryGlobalView } = require("./db/views")
/**
* Given an email address this will use a view to search through
* all the users to find one with this email address.
* @param {string} email the email to lookup the user by.
* @return {Promise<object|null>}
*/
exports.getGlobalUserByEmail = async email => {
if (email == null) {
throw "Must supply an email address to view"
}
2022-04-12 23:34:36 +12:00
const response = await queryGlobalView(ViewNames.USER_BY_EMAIL, {
2022-04-08 12:28:22 +12:00
key: email.toLowerCase(),
include_docs: true,
})
2022-04-12 23:34:36 +12:00
return response
2022-04-08 12:28:22 +12:00
}