fixed subdomain for problem

This commit is contained in:
David Baldwynn 2016-11-02 12:11:41 -07:00
parent ecfccd803f
commit 2d15ae3dd5
5 changed files with 14 additions and 9 deletions

View file

@ -226,7 +226,6 @@ exports.read = function(req, res) {
});
}
return res.json(newForm);
};
/**

View file

@ -7,11 +7,11 @@ var forms = require('../../app/controllers/forms.server.controller'),
core = require('../../app/controllers/core.server.controller');
module.exports = function(app) {
// Root routing
// Core routing
app.route('/').get(core.index);
app.route('/subdomain/api/').get(core.redoc);
app.route('/subdomain/^(?!api$)[A-Za-z0-9]*/').get(core.form);
app.route('/subdomain/^(?!api$)[A-Za-z0-9]*/forms/:formId([a-zA-Z0-9]+)')
.get(forms.read)
app.route('/subdomain/:userSlug((?!api$)[A-Za-z0-9]+)/').get(core.form);
app.route('/subdomain/:userSlug((?!api$)[A-Za-z0-9]+)/forms/:formId([a-zA-Z0-9]+)').get(forms.read)
.post(forms.createSubmission);
};

View file

@ -31,7 +31,7 @@ if( fs.existsSync('./config/env/api_keys.js') ){
exports,
require('./env/api_keys')
);
}else {
} else {
module.exports = exports;
}

View file

@ -81,8 +81,14 @@ module.exports = function(db) {
var urlPath = url.parse(req.url).path.split('/');
if(urlPath.indexOf('static') > -1){
//console.log("STATIC FILE\n\n\n\n");
urlPath.splice(1,1);
req.root = 'https://' + config.baseUrl + urlPath.join('/');
console.log(req.root);
return next();
}
if(urlPath.indexOf('users') > -1 && urlPath.indexOf('me') > -1){
return next();
}
@ -105,8 +111,7 @@ module.exports = function(db) {
}
User.findOne({username: req.subdomains.reverse()[0]}).exec(function (err, user) {
console.log("user");
console.log(user);
if (err) {
console.log(err);
req.subdomains = null;
@ -127,6 +132,7 @@ module.exports = function(db) {
// TODO: check path and query strings are preserved
// reassign url
console.log("path: "+path);
req.url = path;
req.userId = user._id;

View file

@ -8,7 +8,7 @@ var __indexOf = [].indexOf || function(item) {
return -1;
};
angular.module('forms').directive('fieldDirective', ['$http', '$compile', '$rootScope', '$templateCache', 'supportedFields',
angular.module('view-form').directive('fieldDirective', ['$http', '$compile', '$rootScope', '$templateCache', 'supportedFields',
function($http, $compile, $rootScope, $templateCache, supportedFields) {
var getTemplateUrl = function(fieldType) {