diff --git a/app/models/form.server.model.js b/app/models/form.server.model.js index 1ed18629..e8cdbcff 100644 --- a/app/models/form.server.model.js +++ b/app/models/form.server.model.js @@ -134,7 +134,7 @@ FormSchema.pre('save', function (next) { //Convert types from FDF to 'FormField' types if(_typeConvMap[ field.fieldType+'' ]){ - field.fieldType = _pdfConvMap[ field.fieldType+'' ]; + field.fieldType = _typeConvMap[ field.fieldType+'' ]; } field.created = Date.now(); diff --git a/app/routes/users.server.routes.js b/app/routes/users.server.routes.js index a3005346..01925126 100755 --- a/app/routes/users.server.routes.js +++ b/app/routes/users.server.routes.js @@ -10,12 +10,12 @@ module.exports = function(app) { var users = require('../../app/controllers/users.server.controller'); // Setting up the users profile api - app.route('/users/me').get(users.me); - app.route('/users').put(users.update); - app.route('/users/accounts').delete(users.removeOAuthProvider); + app.route('/users/me').get(users.requiresLogin, users.me); + app.route('/users').put(users.requiresLogin, users.update); + app.route('/users/accounts').delete(users.requiresLogin, users.removeOAuthProvider); // Setting up the users password api - app.route('/users/password').post(users.changePassword); + app.route('/users/password').post(users.requiresLogin, users.changePassword); app.route('/auth/forgot').post(users.forgot); app.route('/auth/reset/:token').get(users.validateResetToken); app.route('/auth/reset/:token').post(users.reset); diff --git a/data1435634800654.fdf b/data1435634800654.fdf new file mode 100644 index 00000000..f6a09883 --- /dev/null +++ b/data1435634800654.fdf @@ -0,0 +1,16 @@ +%FDF-1.2 +%âãÏÓ +1 0 obj +<< +/FDF +<< +/Fields [] +>> +>> +endobj +trailer + +<< +/Root 1 0 R +>> +%%EOF \ No newline at end of file diff --git a/public/application.js b/public/application.js index 4b242797..be5a2704 100755 --- a/public/application.js +++ b/public/application.js @@ -9,15 +9,15 @@ angular.module(ApplicationConfiguration.applicationModuleName).config(['$locatio $locationProvider.hashPrefix('!'); } ]); -angular.module(ApplicationConfiguration.applicationModuleName).run(['$rootScope', 'Authorization', 'Principal', - function($rootScope, Authorization, Principal) { +angular.module(ApplicationConfiguration.applicationModuleName).run(['$rootScope', 'Principal', + function($rootScope, Principal) { $rootScope.$on('$stateChangeStart', function(event, toState, toStateParams) { // track the state the user wants to go to; authorization service needs this $rootScope.toState = toState; $rootScope.toStateParams = toStateParams; // if the principal is resolved, do an authorization check immediately. otherwise, // it'll be done when the state it resolved. - if (Principal.isIdentityResolved()) Authorization.authorize(); + // if (Principal.isIdentityResolved()) Authorization.authorize(); }); } ]); diff --git a/public/modules/core/controllers/header.client.controller.js b/public/modules/core/controllers/header.client.controller.js index cfc8820e..4c0d76f7 100755 --- a/public/modules/core/controllers/header.client.controller.js +++ b/public/modules/core/controllers/header.client.controller.js @@ -7,9 +7,10 @@ angular.module('core').controller('HeaderController', ['$scope', 'Principal', 'M $scope.hideNav = false; $scope.menu = Menus.getMenu('topbar'); - Principal.identity().then(function(user){ - $scope.authentication.user = user; - }).then(function(){ + // Principal.identity().then(function(user){ + // $scope.authentication.user = user; + // }).then(function(){ + $scope.authentication.user = Principal.identity(); $scope.signout = function() { var response_obj = Principal.signout(); if( angular.isDefined(response_obj.error) ){ @@ -34,7 +35,7 @@ angular.module('core').controller('HeaderController', ['$scope', 'Principal', 'M } } }); - }); + // }); } ]); \ No newline at end of file diff --git a/public/modules/core/controllers/home.client.controller.js b/public/modules/core/controllers/home.client.controller.js index f0bdce33..ca686bee 100755 --- a/public/modules/core/controllers/home.client.controller.js +++ b/public/modules/core/controllers/home.client.controller.js @@ -5,10 +5,15 @@ angular.module('core').controller('HomeController', ['$scope', 'Principal', function($scope, Principal) { // This provides Principal context. $scope.authentication = Principal; - $scope.authentication.user = undefined; - Principal.identity().then(function(user){ - $scope.authentication.user = user; - }); + $scope.authentication.user = Principal.identity(); + + console.log($scope.authentication.user); + // Principal.identity().then(function(user){ + // console.log(user); + // $scope.authentication.user = user; + // }, function(){ + // console.log('error'); + // }); // console.log("user.displayName: "+Principal.user()._id); } diff --git a/public/modules/users/controllers/authentication.client.controller.js b/public/modules/users/controllers/authentication.client.controller.js index 8c596053..6181cb50 100755 --- a/public/modules/users/controllers/authentication.client.controller.js +++ b/public/modules/users/controllers/authentication.client.controller.js @@ -10,13 +10,14 @@ angular.module('users').controller('AuthenticationController', ['$scope', '$http if ($scope.authentication.isAuthenticated()) $state.go('home'); $scope.signup = function() { - var response_obj = Principal.signup($scope.credentials); - - if( angular.isDefined(response_obj.error) ){ - $scope.error = response_obj.error; - } else{ - $state.go('home'); - } + Principal.signup($scope.credentials).then( + function(result){ + $state.go('home'); + }, + function(rejection_reason){ + $scope.error = rejection_reason; + } + ); // $http.post('/auth/signup', $scope.credentials).success(function(response) { // // If successful we assign the response to the global user model // $scope.authentication.user = response; @@ -30,13 +31,22 @@ angular.module('users').controller('AuthenticationController', ['$scope', '$http $scope.signin = function() { console.log('signin'); - var response_obj = Principal.signin($scope.credentials); - if( angular.isDefined(response_obj.error) ){ - $scope.error = response_obj.error; - $location.path('/signin'); - } else{ - $location.path('/'); - } + + Principal.signin($scope.credentials).then( + function(result){ + $state.go('home'); + }, + function(rejection_reason){ + $scope.error = rejection_reason; + } + ); + // var response_obj = Principal.signin($scope.credentials); + // if( angular.isDefined(response_obj.error) ){ + // $scope.error = response_obj.error; + // $location.path('/signin'); + // } else{ + // $location.path('/'); + // } // $http.post('/auth/signin', $scope.credentials).success(function(response) { // // If successful we assign the response to the global user model // $scope.authentication.user = response; diff --git a/public/modules/users/controllers/settings.client.controller.js b/public/modules/users/controllers/settings.client.controller.js index 8e463254..4b9c274c 100755 --- a/public/modules/users/controllers/settings.client.controller.js +++ b/public/modules/users/controllers/settings.client.controller.js @@ -3,9 +3,10 @@ angular.module('users').controller('SettingsController', ['$scope', '$http', '$state', 'Users', 'Principal', function($scope, $http, $state, Users, Principal) { - Principal.identity().then(function(user){ - $scope.user = user; - }).then(function(){ + // Principal.identity().then(function(user){ + // $scope.user = user; + // }).then(function(){ + $scope.user = Principal.identity(); // If user is not signed in then redirect back home if (!$scope.user) $state.go('home'); @@ -71,6 +72,6 @@ angular.module('users').controller('SettingsController', ['$scope', '$http', '$s }); }; - }); + // }); } ]); \ No newline at end of file diff --git a/public/modules/users/services/authorization.client.service.js b/public/modules/users/services/authorization.client.service.js index 46d79914..b75ca84c 100644 --- a/public/modules/users/services/authorization.client.service.js +++ b/public/modules/users/services/authorization.client.service.js @@ -1,28 +1,28 @@ -'use strict'; +// 'use strict'; -angular.module('users').service('Authorization', ['$rootScope', '$location', 'Principal', - function($rootScope, $location, Principal) { +// angular.module('users').service('Authorization', ['$rootScope', '$location', 'Principal', +// function($rootScope, $location, Principal) { - this.authorize = function() { - return Principal.identity().then(function(){ - var isAuthenticated = Principal.isAuthenticated(); - if( angular.isDefined($rootScope.toState.data) ){ - // if ($rootScope.toState.data.roles && $rootScope.toState.data.roles.length > 0 && !principal.isInAnyRole($rootScope.toState.data.roles)) { - if (!isAuthenticated){ //$location.path('/access_denied'); // user is signed in but not authorized for desired state - // console.log('isAuthenticated: '+isAuthenticated); +// this.authorize = function() { +// return Principal.identity().then(function(){ +// var isAuthenticated = Principal.isAuthenticated(); +// if( angular.isDefined($rootScope.toState.data) ){ +// // if ($rootScope.toState.data.roles && $rootScope.toState.data.roles.length > 0 && !principal.isInAnyRole($rootScope.toState.data.roles)) { +// if (!isAuthenticated){ //$location.path('/access_denied'); // user is signed in but not authorized for desired state +// // console.log('isAuthenticated: '+isAuthenticated); - // else { - // user is not authenticated. so the state they wanted before you - // send them to the signin state, so you can return them when you're done - $rootScope.returnToState = $rootScope.toState; - $rootScope.returnToStateParams = $rootScope.toStateParams; +// // else { +// // user is not authenticated. so the state they wanted before you +// // send them to the signin state, so you can return them when you're done +// $rootScope.returnToState = $rootScope.toState; +// $rootScope.returnToStateParams = $rootScope.toStateParams; - // now, send them to the signin state so they can log in - $location.path('/signin'); - } - // } - } - }); - }; - } -]); \ No newline at end of file +// // now, send them to the signin state so they can log in +// $location.path('/signin'); +// } +// // } +// } +// }); +// }; +// } +// ]); \ No newline at end of file diff --git a/public/modules/users/services/principal.client.service.js b/public/modules/users/services/principal.client.service.js index 78a22d9e..a3c76e9d 100755 --- a/public/modules/users/services/principal.client.service.js +++ b/public/modules/users/services/principal.client.service.js @@ -2,23 +2,24 @@ angular.module('users').factory('Principal', ['$window', '$http', '$q', '$timeout', '$state', function($window, $http, $q, $timeout, $state) { - var _identity, - _authenticated = false; - return { + var service = { + _currentUser: null, + isIdentityResolved: function() { - return angular.isDefined(_identity); + if(service._currentUser === null) return false + return true; }, isAuthenticated: function() { - return _authenticated; + return !!service._currentUser; }, isInRole: function(role) { - if (!_authenticated || !_identity.roles) return false; + if (!service.isAuthenticated() || !service._currentUser.roles) return false; - return _identity.roles.indexOf(role) !== -1; + return service._currentUser.roles.indexOf(role) !== -1; }, isInAnyRole: function(roles) { - if (!_authenticated || !_identity.roles) return false; + if (!service.isAuthenticated() || !service._currentUser.roles) return false; for (var i = 0; i < roles.length; i++) { if (this.isInRole(roles[i])) return true; @@ -27,24 +28,23 @@ angular.module('users').factory('Principal', ['$window', '$http', '$q', '$timeou return false; }, authenticate: function(user) { - _identity = user; - _authenticated = (user !== null); - - // for this demo, we'll store the identity in localStorage. For you, it could be a cookie, sessionStorage, whatever + service._currentUser = user; + + // store the user in $window if (user) $window.user = user; else $window.user = null; }, signin: function(credentials) { var deferred = $q.defer(); - var self = this; $http.post('/auth/signin', credentials).success(function(response) { + console.log(response); // If successful we assign the response to the global user model - self.authenticate(response); + service.authenticate(response); deferred.resolve(response); - }).error(function(response) { - _authenticated = false; - deferred.resolve({ error: response.message }); + }).error(function(error) { + + deferred.reject(error.message || error); }); return deferred.promise; }, @@ -55,9 +55,9 @@ angular.module('users').factory('Principal', ['$window', '$http', '$q', '$timeou $http.post('/auth/signup', credentials).success(function(response) { // If successful we assign the response to the global user model deferred.resolve(response); - }).error(function(response) { + }).error(function(error) { - deferred.resolve({ error: response.message }); + deferred.reject(error.message || error); }); return deferred.promise; @@ -66,63 +66,66 @@ angular.module('users').factory('Principal', ['$window', '$http', '$q', '$timeou var deferred = $q.defer(); $http.get('/auth/signout').success(function(response) { // If successful we assign the response to the global user model - deferred.resolve({}); - }).error(function(response) { - deferred.resolve({ error: response.message }); + deferred.resolve(null); + service.authenticate(null); + }).error(function(error) { + deferred.reject(error.message || error); }); - _authenticated = false; - _identity = undefined; - return deferred.promise; }, - identity: function(force) { - var self = this; + identity: function() { - var deferred = $q.defer(); - - if (force === true) _identity = undefined; - - // check and see if we have retrieved the user data from the server. if we have, reuse it by immediately resolving - if (angular.isDefined(_identity)) { - - deferred.resolve(_identity); - return deferred.promise; - }else if($window.user){ - // console.log($window.user); - // self.authenticate($window.user); - // var user = $window.user; - _identity = $window.user; - self.authenticate(_identity); - deferred.resolve(_identity); - - return deferred.promise; + if (service.isAuthenticated()) { + return service._currentUser; + } else if($window.user){ + service.authenticate($window.user); + return service._currentUser; }else { - - // otherwise, retrieve the user data from the server, update the user object, and then resolve. - $http.get('/users/me', { ignoreErrors: true }) - .success(function(response) { - self.authenticate(response); - $window.user = response; - deferred.resolve(_identity); - }) - .error(function() { - _identity = null; - _authenticated = false; - $window.user = null; - $state.path('signin'); - deferred.resolve(_identity); - }); - - return deferred.promise; + return $http.get('/user/me') + .success(function(response) { + service.authenticate(response.data.user); + return response.data.user; + }) + .error(function() { + service.authenticate(null); + // $state.go('signin'); + return null; + }); } - }, - getUser: function(){ - this.identity(false).then( function(user){ - return user; - }); + + // var deferred = $q.defer(); + + // console.log($window.user); + // console.log(service.isAuthenticated()); + + // // check and see if we have retrieved the user data from the server. if we have, reuse it by immediately resolving + // if (service.isAuthenticated() === true ) { + // deferred.resolve(service.currentUser); + // }else if($window.user){ + + // service.authenticate($window.user); + // deferred.resolve(service._currentUser); + // }else { + + // // otherwise, retrieve the user data from the server, update the user object, and then resolve. + // $http.get('/users/me') + // .success(function(response) { + // service.authenticate(response); + // deferred.resolve(response); + // }) + // .error(function() { + // service.authenticate(null); + // deferred.reject("User's session has expired"); + // }); + // } + + // return deferred.promise; + } }; + + return service; } ]); diff --git a/uploads/pdfs/snthsnthsnth_submission_1435632549359.pdf b/uploads/pdfs/snthsnthsnth_submission_1435632549359.pdf new file mode 100644 index 00000000..23460f8e Binary files /dev/null and b/uploads/pdfs/snthsnthsnth_submission_1435632549359.pdf differ diff --git a/uploads/pdfs/snthsnthsnth_submission_1435632661000.pdf b/uploads/pdfs/snthsnthsnth_submission_1435632661000.pdf new file mode 100644 index 00000000..23460f8e Binary files /dev/null and b/uploads/pdfs/snthsnthsnth_submission_1435632661000.pdf differ diff --git a/uploads/pdfs/snthsnthsnth_submission_1435632781061.pdf b/uploads/pdfs/snthsnthsnth_submission_1435632781061.pdf new file mode 100644 index 00000000..23460f8e Binary files /dev/null and b/uploads/pdfs/snthsnthsnth_submission_1435632781061.pdf differ diff --git a/uploads/pdfs/snthsnthsnth_submission_1435632856522.pdf b/uploads/pdfs/snthsnthsnth_submission_1435632856522.pdf new file mode 100644 index 00000000..23460f8e Binary files /dev/null and b/uploads/pdfs/snthsnthsnth_submission_1435632856522.pdf differ diff --git a/uploads/pdfs/snthsnthsnth_submission_1435632957499.pdf b/uploads/pdfs/snthsnthsnth_submission_1435632957499.pdf new file mode 100644 index 00000000..23460f8e Binary files /dev/null and b/uploads/pdfs/snthsnthsnth_submission_1435632957499.pdf differ diff --git a/uploads/pdfs/snthsnthsnth_submission_1435632962281.pdf b/uploads/pdfs/snthsnthsnth_submission_1435632962281.pdf new file mode 100644 index 00000000..23460f8e Binary files /dev/null and b/uploads/pdfs/snthsnthsnth_submission_1435632962281.pdf differ diff --git a/uploads/pdfs/snthsnthsnth_submission_1435633073378.pdf b/uploads/pdfs/snthsnthsnth_submission_1435633073378.pdf new file mode 100644 index 00000000..23460f8e Binary files /dev/null and b/uploads/pdfs/snthsnthsnth_submission_1435633073378.pdf differ diff --git a/uploads/pdfs/snthsnthsnth_submission_1435633149735.pdf b/uploads/pdfs/snthsnthsnth_submission_1435633149735.pdf new file mode 100644 index 00000000..23460f8e Binary files /dev/null and b/uploads/pdfs/snthsnthsnth_submission_1435633149735.pdf differ diff --git a/uploads/pdfs/snthsnthsnth_submission_1435633184152.pdf b/uploads/pdfs/snthsnthsnth_submission_1435633184152.pdf new file mode 100644 index 00000000..23460f8e Binary files /dev/null and b/uploads/pdfs/snthsnthsnth_submission_1435633184152.pdf differ diff --git a/uploads/pdfs/snthsnthsnth_submission_1435633203001.pdf b/uploads/pdfs/snthsnthsnth_submission_1435633203001.pdf new file mode 100644 index 00000000..23460f8e Binary files /dev/null and b/uploads/pdfs/snthsnthsnth_submission_1435633203001.pdf differ diff --git a/uploads/pdfs/snthsnthsnth_submission_1435633260318.pdf b/uploads/pdfs/snthsnthsnth_submission_1435633260318.pdf new file mode 100644 index 00000000..23460f8e Binary files /dev/null and b/uploads/pdfs/snthsnthsnth_submission_1435633260318.pdf differ diff --git a/uploads/pdfs/snthsnthsnth_submission_1435633896176.pdf b/uploads/pdfs/snthsnthsnth_submission_1435633896176.pdf new file mode 100644 index 00000000..23460f8e Binary files /dev/null and b/uploads/pdfs/snthsnthsnth_submission_1435633896176.pdf differ diff --git a/uploads/pdfs/snthsnthsnth_submission_1435634016101.pdf b/uploads/pdfs/snthsnthsnth_submission_1435634016101.pdf new file mode 100644 index 00000000..23460f8e Binary files /dev/null and b/uploads/pdfs/snthsnthsnth_submission_1435634016101.pdf differ diff --git a/uploads/tmp/1435634600171.pdf b/uploads/tmp/1435634600171.pdf new file mode 100644 index 00000000..e090513d Binary files /dev/null and b/uploads/tmp/1435634600171.pdf differ diff --git a/uploads/tmp/1435634785530.pdf b/uploads/tmp/1435634785530.pdf new file mode 100644 index 00000000..e090513d Binary files /dev/null and b/uploads/tmp/1435634785530.pdf differ diff --git a/uploads/tmp/1435634989526.pdf b/uploads/tmp/1435634989526.pdf new file mode 100644 index 00000000..e090513d Binary files /dev/null and b/uploads/tmp/1435634989526.pdf differ diff --git a/uploads/tmp/1435635144882.pdf b/uploads/tmp/1435635144882.pdf new file mode 100644 index 00000000..e090513d Binary files /dev/null and b/uploads/tmp/1435635144882.pdf differ diff --git a/uploads/tmp/1435635243340.pdf b/uploads/tmp/1435635243340.pdf new file mode 100644 index 00000000..e090513d Binary files /dev/null and b/uploads/tmp/1435635243340.pdf differ diff --git a/uploads/tmp/1435635881310.pdf b/uploads/tmp/1435635881310.pdf new file mode 100644 index 00000000..e090513d Binary files /dev/null and b/uploads/tmp/1435635881310.pdf differ diff --git a/uploads/tmp/1435636804671.pdf b/uploads/tmp/1435636804671.pdf new file mode 100644 index 00000000..e090513d Binary files /dev/null and b/uploads/tmp/1435636804671.pdf differ diff --git a/uploads/tmp/1435637027799.pdf b/uploads/tmp/1435637027799.pdf new file mode 100644 index 00000000..b93e7316 Binary files /dev/null and b/uploads/tmp/1435637027799.pdf differ