Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
dfahlander committed Dec 17, 2023
1 parent cb39e58 commit f55f847
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@ export function createImplicitPropSetterMiddleware(
const trans = req.trans as DBCoreTransaction & TXExpandos;
if (db.cloud.schema?.[tableName]?.markedForSync) {
if (req.type === 'add' || req.type === 'put') {
if (tableName === 'members') {
for (const member of req.values) {
if (typeof member.email === 'string') {
// Resolve https://github.com/dexie/dexie-cloud/issues/4
// If adding a member, make sure email is lowercase and trimmed.
// This is to avoid issues where the APP does not check this
// and just allows the user to enter an email address that might
// have been pasted by the user from a source that had a trailing
// space or was in uppercase. We want to avoid that the user
// creates a new member with a different email address than
// the one he/she intended to create.
member.email = member.email.trim().toLowerCase();
}
}
}
// No matter if user is logged in or not, make sure "owner" and "realmId" props are set properly.
// If not logged in, this will be changed upon syncification of the tables (next sync after login),
// however, application code will work better if we can always rely on that the properties realmId
Expand Down

0 comments on commit f55f847

Please sign in to comment.