Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const router = express.Router();
- router.post('/', function (req, res) {
- var data = req.body;
- var password = bCrypt.hashSync(data.password);
- UserDetails.findOne({
- username: data.email
- }, function (err, user) {
- if (user) {
- console.log(user.username + ' already exist');
- res.send({
- 'status': false,
- 'message': 'email already exist'
- });
- } else {
- var newUser = new UserDetails({
- email: data.email,
- password: password,
- fullName: data.fullName,
- mobile: data.mobile,
- siteAddress: data.siteAddress
- });
- newUser.save(function (err) {
- if (!err) {
- var newSubDomainName = data.siteAddress;
- console.log("newSubDomainName: " + newSubDomainName);
- // var newSubDomainName = "sd4";
- var subDomainCommand = util.format('./setup.sh \"%s\"', newSubDomainName);
- console.log("Creating new user web server cluster" + newSubDomainName);
- console.log("subDomainCommand: " + subDomainCommand);
- exec(subDomainCommand, function (error, stdout, stderr) {
- console.log("Outpput:\n" + stdout);
- console.log("sending success to client...");
- res.send({
- 'status': true,
- 'message': 'successfully registered'
- });
- });
- } else {
- res.send({
- 'status': false,
- 'message': 'internal error. try again'
- });
- }
- });
- }
- });
- });
- module.exports = router;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement