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

View file

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

View file

@ -8,7 +8,7 @@ var __indexOf = [].indexOf || function(item) {
return -1; 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) { function($http, $compile, $rootScope, $templateCache, supportedFields) {
var getTemplateUrl = function(fieldType) { var getTemplateUrl = function(fieldType) {