Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[api] Make sure users set a password during confirmation.

  • Loading branch information...
commit 195c112aeec330b3705ec83780a33c085b863141 1 parent 35d0080
Charlie McConnell AvianFlu authored
Showing with 22 additions and 4 deletions.
  1. +22 −4 lib/jitsu/commands/users.js
26 lib/jitsu/commands/users.js
View
@@ -168,13 +168,31 @@ users.confirm = function (username, callback) {
};
winston.info('Confirming user ' + username.magenta);
- jitsu.users.confirm(user, function (err, result) {
+ jitsu.users.confirm(user, function (err, response) {
if (err) {
return callback(err);
}
-
- if (result.error) {
- winston.error(result.error);
+ if (response.error) {
+ winston.error(response.error);
+ }
+ else if (!response.hasPassword) {
+ (function getNewPass() {
+ jitsu.prompt.get(['password', 'confirm password'], function (err, results) {
+ if (err) {
+ return callback(err);
+ }
+ if (results['password'] !== results['confirm password']) {
+ winston.error('The provided passwords do not match.');
+ return getNewPass();
+ }
+ jitsu.users.forgot(username, {
+ shake: response.shake,
+ 'new-password': results.password
+ }, function (err, res) {
+ return err ? callback(err) : callback(null, res);
+ });
+ });
+ })();
}
else {
winston.info('User ' + username.magenta + ' confirmed');
Please sign in to comment.
Something went wrong with that request. Please try again.