Browse Source

feat: ignore empty string and null for user input email

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/7202/head
mertmit 12 months ago
parent
commit
3a46468f8a
  1. 11
      packages/nocodb/src/db/BaseModelSqlv2.ts

11
packages/nocodb/src/db/BaseModelSqlv2.ts

@ -5483,6 +5483,7 @@ class BaseModelSqlv2 {
.map((u) => u.trim()); .map((u) => u.trim());
for (const user of users) { for (const user of users) {
try { try {
if (user.length === 0) continue;
if (user.includes('@')) { if (user.includes('@')) {
const u = baseUsers.find((u) => u.email === user); const u = baseUsers.find((u) => u.email === user);
if (!u) { if (!u) {
@ -5509,13 +5510,19 @@ class BaseModelSqlv2 {
for (const userObj of users) { for (const userObj of users) {
const user = extractProps(userObj, ['id', 'email']); const user = extractProps(userObj, ['id', 'email']);
try { try {
if (user.id) { if ('id' in user) {
const u = baseUsers.find((u) => u.id === user.id); const u = baseUsers.find((u) => u.id === user.id);
if (!u) { if (!u) {
throw new Error(`User with id '${user.id}' not found`); throw new Error(`User with id '${user.id}' not found`);
} }
userIds.push(u.id); userIds.push(u.id);
} else if (user.email) { } else if ('email' in user) {
// skip null input
if (!user.email) continue;
// trim extra spaces
user.email = user.email.trim();
// skip empty input
if (user.email.length === 0) continue;
const u = baseUsers.find((u) => u.email === user.email); const u = baseUsers.find((u) => u.email === user.email);
if (!u) { if (!u) {
throw new Error( throw new Error(

Loading…
Cancel
Save