Add fallbackEmail to user data model

This commit is contained in:
Johannes Zellner
2018-01-21 14:25:39 +01:00
parent 00c1c42b58
commit 1e8aa209b1
4 changed files with 20 additions and 4 deletions
+7
View File
@@ -166,6 +166,7 @@ function createUser(username, password, email, displayName, auditSource, options
id: 'uid-' + uuid.v4(),
username: username,
email: email,
fallbackEmail: email, // for new users the fallbackEmail is also the default email
password: new Buffer(derivedKey, 'binary').toString('hex'),
salt: salt.toString('hex'),
createdAt: now,
@@ -399,6 +400,12 @@ function updateUser(userId, data, auditSource, callback) {
if (error) return callback(error);
}
if (data.fallbackEmail) {
data.fallbackEmail = data.fallbackEmail.toLowerCase();
error = validateEmail(data.fallbackEmail);
if (error) return callback(error);
}
userdb.get(userId, function (error) {
if (error && error.reason === DatabaseError.NOT_FOUND) return callback(new UserError(UserError.NOT_FOUND));
if (error) return callback(new UserError(UserError.INTERNAL_ERROR, error));