1
0
Fork 0
mirror of synced 2024-08-18 19:41:30 +12:00

Merge pull request #7082 from Budibase/sev1/login-new-users

Fix login for new users
This commit is contained in:
Rory Powell 2022-08-04 12:04:06 +01:00 committed by GitHub
commit 47b324a36c

View file

@ -101,7 +101,7 @@ interface SaveUserOpts {
bulkCreate?: boolean bulkCreate?: boolean
} }
export const buildUser = async ( const buildUser = async (
user: any, user: any,
opts: SaveUserOpts = { opts: SaveUserOpts = {
hashPassword: true, hashPassword: true,
@ -195,6 +195,11 @@ export const save = async (
dbUser dbUser
) )
// make sure we set the _id field for a new user
if (!_id) {
_id = builtUser._id
}
try { try {
const putOpts = { const putOpts = {
password: builtUser.password, password: builtUser.password,
@ -220,7 +225,7 @@ export const save = async (
await addTenant(tenantId, _id, email) await addTenant(tenantId, _id, email)
await cache.user.invalidateUser(response.id) await cache.user.invalidateUser(response.id)
// let server know to sync user // let server know to sync user
await apps.syncUserInApps(builtUser._id) await apps.syncUserInApps(_id)
return { return {
_id: response.id, _id: response.id,
@ -305,6 +310,9 @@ export const bulkCreate = async (
// Post processing of bulk added users, i.e events and cache operations // Post processing of bulk added users, i.e events and cache operations
for (const user of usersToBulkSave) { for (const user of usersToBulkSave) {
// TODO: Refactor to bulk insert users into the info db
// instead of relying on looping tenant creation
await addTenant(tenantId, user._id, user.email)
await eventHelpers.handleSaveEvents(user, null) await eventHelpers.handleSaveEvents(user, null)
await apps.syncUserInApps(user._id) await apps.syncUserInApps(user._id)
} }