larvituser
Advanced tools
Comparing version 0.10.1 to 0.10.2
@@ -53,3 +53,3 @@ 'use strict'; | ||
userLib.usernameAvailable(data.global.formFields.username.trim(), function (err, result) { | ||
if (err) { cb(err); return; } | ||
if (err) return cb(err); | ||
@@ -68,3 +68,3 @@ if (result !== true) { | ||
tasks.push(function (cb) { | ||
if (data.global.errors.length) { return cb(); } | ||
if (data.global.errors.length) return cb(); | ||
@@ -88,13 +88,12 @@ userLib.create(data.global.formFields.username, newPassword, userFields, function (err, result) { | ||
if ( ! user) { | ||
throw new Error('Ingen user?!??!'); | ||
throw new Error('No user set'); | ||
} | ||
if (data.global.formFields.username.trim() === user.username) { | ||
cb(); | ||
return; | ||
} | ||
data.global.formFields.username = data.global.formFields.username.trim(); | ||
userLib.usernameAvailable(data.global.formFields.username.trim(), function (err, result) { | ||
if (err) { cb(err); return; } | ||
if (data.global.formFields.username === user.username) return cb(); | ||
userLib.usernameAvailable(data.global.formFields.username, function (err, result) { | ||
if (err) return cb(err); | ||
if (result !== true) { | ||
@@ -109,8 +108,5 @@ data.global.errors.push('Username is taken by another user'); | ||
tasks.push(function (cb) { | ||
if (data.global.formFields.username.trim() === user.username) { | ||
cb(); | ||
return; | ||
} | ||
if (data.global.formFields.username === user.username) return cb(); | ||
if (data.global.errors.length) { return cb(); } | ||
if (data.global.errors.length) return cb(); | ||
@@ -121,5 +117,5 @@ user.setUsername(data.global.formFields.username.trim(), cb); | ||
// Update password | ||
if (data.global.formFields.password.trim() !== '' || newPassword === false) { | ||
if (newPassword !== '' || newPassword === false) { | ||
tasks.push(function (cb) { | ||
if (data.global.errors.length) { return cb(); } | ||
if (data.global.errors.length) return cb(); | ||
@@ -132,3 +128,3 @@ user.setPassword(newPassword, cb); | ||
tasks.push(function (cb) { | ||
if (data.global.errors.length) { return cb(); } | ||
if (data.global.errors.length) return cb(); | ||
@@ -139,7 +135,11 @@ user.replaceFields(userFields, cb); | ||
tasks.push(function (cb) { | ||
if (data.global.errors.length) { return cb(); } | ||
if (data.global.errors.length) return cb(); | ||
req.session.data.nextCallData = {'global': {'messages': ['New user created']}}; | ||
res.statusCode = 302; | ||
res.setHeader('Location', '/adminUsers/edit?uuid=' + user.uuid); | ||
if (data.global.urlParsed.query.uuid === undefined) { | ||
req.session.data.nextCallData = {'global': {'messages': ['New user created']}}; | ||
res.statusCode = 302; | ||
res.setHeader('Location', '/adminUsers/edit?uuid=' + user.uuid); | ||
} else { | ||
data.global.messages = ['Saved']; | ||
} | ||
@@ -153,3 +153,3 @@ cb(); | ||
userLib.rmUser(data.global.urlParsed.query.uuid, function (err) { | ||
if (err) { cb(err); return; } | ||
if (err) return cb(err); | ||
@@ -167,3 +167,3 @@ req.session.data.nextCallData = {'global': {'messages': ['User "' + data.global.urlParsed.query.uuid + '" erased']}}; | ||
userLib.fromUuid(data.global.urlParsed.query.uuid, function (err, user) { | ||
if (err) { cb(err); return; } | ||
if (err) return cb(err); | ||
@@ -170,0 +170,0 @@ data.user = { |
{ | ||
"name": "larvituser", | ||
"version": "0.10.1", | ||
"version": "0.10.2", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "Mikael 'Lilleman' Göransson", |
76089
1977