Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- db.UserModel.find({ 'username': username }, function(error, documents) {
- if (!error) {
- if (documents.length == 0) {
- if (password == confirmation) {
- recaptcha.verify(function(success, errorCode) {
- if (success) {
- var user = new db.UserModel();
- var shasum = crypto.createHash('sha1');
- shasum.update(password);
- // Save to Database
- user.username = username;
- user.password = shasum.digest('hex');
- user.save(function(error) {
- if (!error) {
- req.session.login = username;
- res.json({ 'username': username }, 201);
- }
- else
- res.send('Database error, please try again shortly.', 503);
- });
- }
- else
- res.send('Invalid Captcha.', 400);
- });
- }
- else
- res.send('Wrong password confirmation.', 400);
- }
- else
- res.send('Username already taken by another user.', 400);
- }
- else
- res.send('Database error, please try again shortly.', 503);
- });
Add Comment
Please, Sign In to add comment