Skip to content

Commit 11e22bd

Browse files
committed
moved register to codebox, using webhook too.
1 parent 607825d commit 11e22bd

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

lib/commands/register.js

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const fs = require('fs')
22
, Syncano = require('syncano')
3-
, validator = require('validator');
3+
, validator = require('validator')
4+
, request = require('request')
45
;
56

67
module.exports = function(FASTACK) {
@@ -24,22 +25,28 @@ module.exports = function(FASTACK) {
2425
message: 'Fastack password: '
2526
}
2627
], function(answers) {
27-
var fastack = new Syncano({instance: 'fastack', apiKey: FASTACK.apiKey});
28-
var responses = { username: answers.username, email: answers.email, password: answers.password }
28+
var fastack = new Syncano({instance: 'fastack', apiKey: FASTACK.apiKey, userKey: FASTACK.userKey});
29+
// fastack.webhook('register').run(function(){});
2930

30-
if( answers.email && validator.isEmail( answers.email ) ){
31-
fastack.user().add( responses ).then(function(){
32-
FASTACK.logger.log("Account created.");
33-
callback();
34-
}, function(err){
35-
FASTACK.logger.log("Error info: " + err);
36-
callback();
37-
});
38-
} else {
39-
FASTACK.logger.log("Not a valid e-mail address. Please try again.");
40-
callback();
41-
}
31+
var url = "https://api.syncano.io/v1/instances/fastack/webhooks/p/e0069d7708abccb1bcf09b0b8bc98bec71096378/register/"
32+
33+
request(url, function (err, res) {
34+
if (err) {console.log(err); return;}
35+
console.log(res.body);
36+
});
37+
38+
callback();
39+
// account.instance('INSTANCE_NAME').webhook('WEBHOOK_NAME').run(callback());
40+
// if( answers.email ){ // we only need to account for e-mail bc this.prompt already ensures a username and pw is entered
41+
// var payload = {"payload":{'apiKey': FASTACK.apiKey,'username': answers.username, 'password': answers.password, 'email':answers.email}};
42+
// fastack.codebox(6).run(payload, function(){});
43+
// callback();
44+
// } else {
45+
// FASTACK.logger.log("You must enter an e-mail address. Please try again.");
46+
// callback();
47+
// }
4248

4349
});
50+
4451
}
4552
};

0 commit comments

Comments
 (0)