Handle username conflict in account setup

This commit is contained in:
Johannes Zellner
2016-04-04 12:19:41 +02:00
parent 36f3f4b8f4
commit c73213b2f2
3 changed files with 5 additions and 2 deletions

View File

@@ -191,6 +191,7 @@ function update(userId, user, callback) {
args.push(userId);
database.query('UPDATE users SET ' + fields.join(', ') + ' WHERE id = ?', args, function (error, result) {
if (error && error.code === 'ER_DUP_ENTRY') return callback(new DatabaseError(DatabaseError.ALREADY_EXISTS, error));
if (error) return callback(new DatabaseError(DatabaseError.INTERNAL_ERROR, error));
if (result.affectedRows !== 1) return callback(new DatabaseError(DatabaseError.NOT_FOUND));