Skip to content

Commit

Permalink
GIFT-245
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewNatoli committed Oct 23, 2017
1 parent f6e9321 commit 4378df7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion react-ui/src/app/dashboard/users/NewUser.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default class NewUser extends React.Component<{}, { user: * }> {
window.location = '/dashboard/user';
});
}).catch(() => {
alert('Could not save user. An unknown error has occured.');
alert('Could not save user. An unknown error has occured. Perhaps a user with that email address already exists in the database?');
});
})
}
Expand Down
5 changes: 5 additions & 0 deletions server/apps/nominations/controllers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,15 @@ module.exports = {
if (req.user.role !== 'admin') {
res.status(401);
res.json({ data: null });
return;
}

const { user } = req.body;

if (user.password !== user.password_confirmation) {
res.status(401);
res.json({ data: null });
return;
}
console.log('start');
// Find existing user with that email address
Expand All @@ -116,6 +118,8 @@ module.exports = {
data: null,
message: 'User already exists'
});
console.log('User already exists');
return;
}

db.user.create({
Expand All @@ -131,6 +135,7 @@ module.exports = {
approved: true,
password: auth.hashPassword(user.password),
affiliation_id: user.affiliation_id,
confirmation_email: false
}).then((createdUser) => {
console.log('made a user!', createdUser);
res.json({ data: { user: { id: createdUser.id } } });
Expand Down

0 comments on commit 4378df7

Please sign in to comment.