fixed login/signup bug
This commit is contained in:
parent
dee6945d88
commit
8b8aed337e
|
@ -275,31 +275,32 @@ exports.list = function(req, res) {
|
||||||
exports.formByID = function(req, res, next, id) {
|
exports.formByID = function(req, res, next, id) {
|
||||||
|
|
||||||
if (!mongoose.Types.ObjectId.isValid(id)) {
|
if (!mongoose.Types.ObjectId.isValid(id)) {
|
||||||
res.status(400).send({
|
return res.status(400).send({
|
||||||
message: 'Form is invalid'
|
message: 'Form is invalid'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Form.findById(id).populate('admin').exec(function(err, form) {
|
||||||
|
if (err) {
|
||||||
|
return next(err);
|
||||||
|
} else if (form === undefined || form === null) {
|
||||||
|
res.status(400).send({
|
||||||
|
message: 'Form not found'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// console.log(form.admin);
|
||||||
|
|
||||||
Form.findById(id).populate('admin').exec(function(err, form) {
|
//Remove sensitive information from User object
|
||||||
if (err) {
|
form.admin.password = undefined;
|
||||||
return next(err);
|
form.admin.salt = undefined;
|
||||||
} else if (form === undefined || form === null) {
|
form.provider = undefined;
|
||||||
res.status(400).send({
|
|
||||||
message: 'Form not found'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// console.log(form.admin);
|
|
||||||
|
|
||||||
//Remove sensitive information from User object
|
req.form = form;
|
||||||
form.admin.password = undefined;
|
next();
|
||||||
form.admin.salt = undefined;
|
}
|
||||||
form.provider = undefined;
|
});
|
||||||
|
}
|
||||||
req.form = form;
|
|
||||||
next();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -56,20 +56,35 @@ exports.signup = function(req, res) {
|
||||||
user.username = user.email;
|
user.username = user.email;
|
||||||
|
|
||||||
// Then save the temporary user
|
// Then save the temporary user
|
||||||
nev.createTempUser(user, function(newTempUser) {
|
nev.createTempUser(user, function(err, newTempUser) {
|
||||||
// new user created
|
|
||||||
if (newTempUser) {
|
if (err) {
|
||||||
nev.registerTempUser(newTempUser, function (err) {
|
console.log('Error: ');
|
||||||
if (err) {
|
console.log(err);
|
||||||
return res.status(400).send({
|
res.status(400).send({
|
||||||
message: errorHandler.getErrorMessage(err)
|
message: errorHandler.getErrorMessage(err)
|
||||||
});
|
});
|
||||||
}
|
}else {
|
||||||
res.status(200).send('An email has been sent to you. Please check it to verify your account.');
|
console.log('new tmpuser created');
|
||||||
});
|
// new user created
|
||||||
} else {
|
if (newTempUser) {
|
||||||
return res.status(400).send('Error: Temp user could NOT be created!');
|
nev.registerTempUser(newTempUser, function (err) {
|
||||||
}
|
if (err) {
|
||||||
|
console.log('Error: ');
|
||||||
|
console.log(err);
|
||||||
|
res.status(400).send({
|
||||||
|
message: errorHandler.getErrorMessage(err)
|
||||||
|
});
|
||||||
|
}else {
|
||||||
|
console.log('new tmpuser registered');
|
||||||
|
res.status(200).send('An email has been sent to you. Please check it to verify your account.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.log('Error: Temp user already exists!');
|
||||||
|
res.status(400).send('Error: Temp user already exists!');
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -104,8 +119,8 @@ exports.signin = function(req, res, next) {
|
||||||
*/
|
*/
|
||||||
exports.signout = function(req, res) {
|
exports.signout = function(req, res) {
|
||||||
req.logout();
|
req.logout();
|
||||||
res.status(200).send('Successfully logged out');
|
// res.status(200).send('Successfully logged out');
|
||||||
// res.redirect('/');
|
res.redirect('/');
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -63,10 +63,6 @@ var FormSubmissionSchema = new Schema({
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//Mongoose Relationship initialization
|
|
||||||
// FormSubmissionSchema.plugin(relationship, { relationshipPathName:'form' });
|
|
||||||
|
|
||||||
|
|
||||||
//Check for IP Address of submitting person
|
//Check for IP Address of submitting person
|
||||||
FormSubmissionSchema.pre('save', function (next){
|
FormSubmissionSchema.pre('save', function (next){
|
||||||
if(this.ipAddr){
|
if(this.ipAddr){
|
||||||
|
|
|
@ -8,11 +8,12 @@ var should = require('should'),
|
||||||
app: app
|
app: app
|
||||||
}),
|
}),
|
||||||
mongoose = require('mongoose'),
|
mongoose = require('mongoose'),
|
||||||
User = mongoose.model('User'),
|
url = require('url'),
|
||||||
config = require('../../config/config'),
|
config = require('../../config/config'),
|
||||||
|
User = mongoose.model('User'),
|
||||||
tmpUser = mongoose.model(config.tempUserCollection),
|
tmpUser = mongoose.model(config.tempUserCollection),
|
||||||
agent = request.agent(app),
|
agent = request.agent(app);
|
||||||
url = require('url');
|
|
||||||
|
|
||||||
var mailosaur = require('mailosaur')(config.mailosaur.key),
|
var mailosaur = require('mailosaur')(config.mailosaur.key),
|
||||||
mailbox = new mailosaur.Mailbox(config.mailosaur.mailbox_id);
|
mailbox = new mailosaur.Mailbox(config.mailosaur.mailbox_id);
|
||||||
|
@ -23,12 +24,26 @@ var mandrill = require('node-mandrill')(config.mailer.options.auth.pass);
|
||||||
* Globals
|
* Globals
|
||||||
*/
|
*/
|
||||||
var credentials, _User, _Session;
|
var credentials, _User, _Session;
|
||||||
|
// Create user credentials
|
||||||
|
credentials = {
|
||||||
|
username: 'be1e58fb@mailosaur.in',
|
||||||
|
password: 'password'
|
||||||
|
};
|
||||||
|
|
||||||
|
// Create a new user
|
||||||
|
_User = {
|
||||||
|
firstName: 'Full',
|
||||||
|
lastName: 'Name',
|
||||||
|
email: credentials.username,
|
||||||
|
username: credentials.username,
|
||||||
|
password: credentials.password,
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form routes tests
|
* Form routes tests
|
||||||
*/
|
*/
|
||||||
describe('User CRUD tests', function() {
|
describe('User CRUD tests', function() {
|
||||||
this.timeout(15000);
|
this.timeout(100000);
|
||||||
var userSession;
|
var userSession;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
|
@ -51,98 +66,115 @@ describe('User CRUD tests', function() {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
// describe('Create, Verify and Activate a User', function() {
|
describe('Create, Verify and Activate a User', function() {
|
||||||
var username = 'testActiveAccount.be1e58fb@mailosaur.in';
|
_User.email = _User.username = 'testActiveAccount5.be1e58fb@mailosaur.in';
|
||||||
var link, _tmpUser, activateToken = '';
|
var link, _tmpUser, activateToken = '';
|
||||||
|
|
||||||
it('should be able to create a temporary (non-activated) User', function(done) {
|
before(function(done){
|
||||||
_User.email = _User.username = username;
|
tmpUser.findOne({username: _User.username}, function (err, user) {
|
||||||
request(app).post('/auth/signup')
|
console.log(user);
|
||||||
|
if(user){
|
||||||
|
tmpUser.remove({username: _User.username}, function(err){
|
||||||
|
if(err) done(err)
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
}else {done();}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be able to query /signup', function(done) {
|
||||||
|
|
||||||
|
userSession.post('/auth/signup')
|
||||||
.send(_User)
|
.send(_User)
|
||||||
.expect(200, 'An email has been sent to you. Please check it to verify your account.')
|
.expect(200, 'An email has been sent to you. Please check it to verify your account.')
|
||||||
.end(function(FormSaveErr, FormSaveRes) {
|
.end(function(FormSaveErr, FormSaveRes) {
|
||||||
// (FormSaveRes.text).should.equal('An email has been sent to you. Please check it to verify your account.');
|
should.not.exist(FormSaveErr);
|
||||||
done();
|
done();
|
||||||
// tmpUser.findOne({username: _User.username}, function (err, user) {
|
|
||||||
// should.not.exist(err);
|
|
||||||
// should.exist(user);
|
|
||||||
// _tmpUser = user;
|
|
||||||
|
|
||||||
// _User.username.should.equal(user.username);
|
|
||||||
// _User.firstName.should.equal(user.firstName);
|
|
||||||
// _User.lastName.should.equal(user.lastName);
|
|
||||||
|
|
||||||
// // mandrill('/messages/search', {
|
|
||||||
// // query: "subject:Confirm",
|
|
||||||
// // senders: [
|
|
||||||
// // "test@forms.polydaic.com"
|
|
||||||
// // ],
|
|
||||||
// // limit: 1
|
|
||||||
// // }, function(error, emails) {
|
|
||||||
// // if (error) console.log( JSON.stringify(error) );
|
|
||||||
|
|
||||||
// // var confirmation_email = emails[0];
|
|
||||||
|
|
||||||
// // mandrill('/messages/content', {
|
|
||||||
// // id: confirmation_email._id
|
|
||||||
// // }, function(error, email) {
|
|
||||||
// // if (error) console.log( JSON.stringify(error) );
|
|
||||||
|
|
||||||
// // // console.log(email);
|
|
||||||
// // var link = _(email.text.split('\n')).reverse().value()[1];
|
|
||||||
// // console.log(link);
|
|
||||||
// // activateToken = _(url.parse(link).hash.split('/')).reverse().value()[0];
|
|
||||||
// // console.log('actual activateToken: '+ activateToken);
|
|
||||||
// // console.log('expected activateToken: ' + user.GENERATED_VERIFYING_URL);
|
|
||||||
|
|
||||||
// // done();
|
|
||||||
|
|
||||||
// // });
|
|
||||||
// // });
|
|
||||||
|
|
||||||
|
|
||||||
// // mailbox.getEmails(function(err, _emails) {
|
|
||||||
// // if(err) done(err);
|
|
||||||
|
|
||||||
// // var emails = _emails;
|
|
||||||
|
|
||||||
// // console.log('mailbox.getEmails:');
|
|
||||||
// // console.log(emails[0].text.links);
|
|
||||||
|
|
||||||
// // var link = emails[0].text.links[0].href;
|
|
||||||
// // activateToken = _(url.parse(link).hash.split('/')).reverse().value()[0];
|
|
||||||
// // console.log('actual activateToken: '+ activateToken);
|
|
||||||
// // console.log('expected activateToken: ' + user.GENERATED_VERIFYING_URL);
|
|
||||||
// // (activateToken).should.equal(user.GENERATED_VERIFYING_URL);
|
|
||||||
|
|
||||||
// // done();
|
|
||||||
// // });
|
|
||||||
// });
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// it('should be able to verify a User Account', function(done) {
|
it('should have created a temporary user', function(done){
|
||||||
// userSession.get('/auth/verify/'+activateToken)
|
tmpUser.findOne({username: _User.username}).exec(function (err, user) {
|
||||||
// .expect(200)
|
should.not.exist(err);
|
||||||
// .end(function(VerifyErr, VerifyRes) {
|
should.exist(user);
|
||||||
// should.not.exist(VerifyErr);
|
_tmpUser = user;
|
||||||
// (VerifyRes.text).should.equal('User successfully verified');
|
|
||||||
// done();
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('should receive confirmation email after verifying a User Account', function(done) {
|
_User.username.should.equal(user.username);
|
||||||
// mailbox.getEmails(function(err, _emails) {
|
_User.firstName.should.equal(user.firstName);
|
||||||
// if(err) throw err;
|
_User.lastName.should.equal(user.lastName);
|
||||||
// var email = _emails[0];
|
done();
|
||||||
|
|
||||||
// // console.log('mailbox.getEmails:');
|
// mandrill('/messages/search', {
|
||||||
// console.log(email);
|
// query: "subject:Confirm",
|
||||||
// (email.subject).should.equal('Account successfully verified!');
|
// senders: [
|
||||||
// done();
|
// "test@forms.polydaic.com"
|
||||||
// });
|
// ],
|
||||||
// });
|
// limit: 1
|
||||||
// });
|
// }, function(error, emails) {
|
||||||
|
// if (error) console.log( JSON.stringify(error) );
|
||||||
|
|
||||||
|
// var confirmation_email = emails[0];
|
||||||
|
|
||||||
|
// mandrill('/messages/content', {
|
||||||
|
// id: confirmation_email._id
|
||||||
|
// }, function(error, email) {
|
||||||
|
// if (error) console.log( JSON.stringify(error) );
|
||||||
|
|
||||||
|
// // console.log(email);
|
||||||
|
// var link = _(email.text.split('\n')).reverse().value()[1];
|
||||||
|
// console.log(link);
|
||||||
|
// activateToken = _(url.parse(link).hash.split('/')).reverse().value()[0];
|
||||||
|
// console.log('actual activateToken: '+ activateToken);
|
||||||
|
// console.log('expected activateToken: ' + user.GENERATED_VERIFYING_URL);
|
||||||
|
|
||||||
|
// done();
|
||||||
|
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should have sent a verification email', function(done){
|
||||||
|
|
||||||
|
mailbox.getEmails(function(err, _emails) {
|
||||||
|
if(err) done(err);
|
||||||
|
|
||||||
|
var emails = _emails;
|
||||||
|
|
||||||
|
console.log('mailbox.getEmails:');
|
||||||
|
console.log(emails[0].text.links);
|
||||||
|
|
||||||
|
var link = emails[0].text.links[0].href;
|
||||||
|
activateToken = _(url.parse(link).hash.split('/')).reverse().value()[0];
|
||||||
|
console.log('actual activateToken: '+ activateToken);
|
||||||
|
console.log('expected activateToken: ' + _tmpUser.GENERATED_VERIFYING_URL);
|
||||||
|
(activateToken).should.equal(_tmpUser.GENERATED_VERIFYING_URL);
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be able to verify a User Account', function(done) {
|
||||||
|
userSession.get('/auth/verify/'+activateToken)
|
||||||
|
.expect(200)
|
||||||
|
.end(function(VerifyErr, VerifyRes) {
|
||||||
|
should.not.exist(VerifyErr);
|
||||||
|
(VerifyRes.text).should.equal('User successfully verified');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should receive confirmation email after verifying a User Account', function(done) {
|
||||||
|
mailbox.getEmails(function(err, _emails) {
|
||||||
|
if(err) throw err;
|
||||||
|
var email = _emails[0];
|
||||||
|
|
||||||
|
console.log(email);
|
||||||
|
(email.subject).should.equal('Account successfully verified!');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// it('should be able to login and logout a User', function (done) {
|
// it('should be able to login and logout a User', function (done) {
|
||||||
// var username = 'testActiveAccount.be1e58fb@mailosaur.in';
|
// var username = 'testActiveAccount.be1e58fb@mailosaur.in';
|
||||||
|
|
|
@ -13,19 +13,20 @@ angular.module('forms').config(['$stateProvider',
|
||||||
permissions: [ 'editForm' ]
|
permissions: [ 'editForm' ]
|
||||||
}
|
}
|
||||||
}).
|
}).
|
||||||
|
state('submitForm', {
|
||||||
|
url: '/forms/:formId',
|
||||||
|
templateUrl: 'modules/forms/views/submit-form.client.view.html',
|
||||||
|
data: {
|
||||||
|
hideNav: true,
|
||||||
|
},
|
||||||
|
}).
|
||||||
state('viewForm', {
|
state('viewForm', {
|
||||||
url: '/forms/:formId/admin',
|
url: '/forms/:formId/admin',
|
||||||
templateUrl: 'modules/forms/views/admin-form.client.view.html',
|
templateUrl: 'modules/forms/views/admin-form.client.view.html',
|
||||||
data: {
|
data: {
|
||||||
permissions: [ 'editForm' ]
|
permissions: [ 'editForm' ]
|
||||||
}
|
}
|
||||||
}).
|
});
|
||||||
state('viewPublicForm', {
|
|
||||||
url: '/forms/:formId',
|
|
||||||
templateUrl: 'modules/forms/views/view-public-form.client.view.html',
|
|
||||||
data: {
|
|
||||||
hideNav: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
]);
|
]);
|
|
@ -7,15 +7,23 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$scope
|
||||||
$scope = $rootScope;
|
$scope = $rootScope;
|
||||||
|
|
||||||
$scope.myform = CurrentForm.getForm();
|
$scope.myform = CurrentForm.getForm();
|
||||||
|
$scope.myform._id = $stateParams.formId;
|
||||||
$rootScope.saveInProgress = false;
|
$rootScope.saveInProgress = false;
|
||||||
|
|
||||||
// Find a specific Form
|
// Find a specific Form
|
||||||
$scope.findOne = function(){
|
$scope.findOne = function(){
|
||||||
$scope.myform = Forms.get({
|
Forms.get({
|
||||||
formId: $stateParams.formId
|
formId: $stateParams.formId
|
||||||
|
}, function(form){
|
||||||
|
CurrentForm.setForm(form);
|
||||||
|
$scope.myform = form;
|
||||||
|
$scope.myform._id = $stateParams.formId;
|
||||||
|
}, function(err){
|
||||||
|
console.error('Could not fetch form');
|
||||||
|
console.error(err);
|
||||||
});
|
});
|
||||||
CurrentForm.setForm($scope.myform);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.setForm = function(form){
|
$scope.setForm = function(form){
|
||||||
$scope.myform = form;
|
$scope.myform = form;
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,7 +15,6 @@ angular.module('forms').directive('editSubmissionsFormDirective', ['$rootScope',
|
||||||
rows: []
|
rows: []
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Table Functions
|
** Table Functions
|
||||||
*/
|
*/
|
||||||
|
@ -46,8 +45,6 @@ angular.module('forms').directive('editSubmissionsFormDirective', ['$rootScope',
|
||||||
$http.get('/forms/'+$scope.myform._id+'/submissions')
|
$http.get('/forms/'+$scope.myform._id+'/submissions')
|
||||||
.success(function(data, status, headers){
|
.success(function(data, status, headers){
|
||||||
|
|
||||||
console.log(data[0].form_fields);
|
|
||||||
|
|
||||||
var _tmpSubFormFields,
|
var _tmpSubFormFields,
|
||||||
defaultFormFields = _.cloneDeep($scope.myform.form_fields);
|
defaultFormFields = _.cloneDeep($scope.myform.form_fields);
|
||||||
|
|
||||||
|
@ -68,7 +65,9 @@ angular.module('forms').directive('editSubmissionsFormDirective', ['$rootScope',
|
||||||
.error(function(err){
|
.error(function(err){
|
||||||
console.error('Could not fetch form submissions.\nError: '+err);
|
console.error('Could not fetch form submissions.\nError: '+err);
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
};
|
||||||
|
|
||||||
//Delete selected submissions of Form
|
//Delete selected submissions of Form
|
||||||
$scope.deleteSelectedSubmissions = function(){
|
$scope.deleteSelectedSubmissions = function(){
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
// 'use strict';
|
||||||
|
|
||||||
|
// angular.module('forms').directive('entryPage', ['$templateCache', '$http', '$compile', '$rootScope',
|
||||||
|
// function($templateCache, $http, $compile, $rootScope) {
|
||||||
|
// var getTemplateUrl = function(type) {
|
||||||
|
|
||||||
|
// var templateUrl = 'modules/forms/views/directiveViews/entryPage/';
|
||||||
|
// var supported_pages = [
|
||||||
|
// 'welcome',
|
||||||
|
// 'thankyou'
|
||||||
|
// ];
|
||||||
|
// if (__indexOf.call(supported_pages, type) >= 0) {
|
||||||
|
// templateUrl += type + '.html';
|
||||||
|
// }
|
||||||
|
// var template = $templateCache.get(templateUrl);
|
||||||
|
// return template;
|
||||||
|
// };
|
||||||
|
// return {
|
||||||
|
// restrict: 'E',
|
||||||
|
// template: '<div>Start Page</div>',
|
||||||
|
// scope: {
|
||||||
|
// 'pageData': '=',
|
||||||
|
// 'pageType': '&'
|
||||||
|
// },
|
||||||
|
// link: function(scope, element) {
|
||||||
|
|
||||||
|
// // console.log(attrs);
|
||||||
|
// console.log('scope.pageData');
|
||||||
|
// // console.log(scope);
|
||||||
|
// scope.exitStartPage = function() {
|
||||||
|
// // console.log(scope.pageData);
|
||||||
|
// // if(attrs.pageData.showStart) attrs.pageData.showStart = false;
|
||||||
|
// };
|
||||||
|
|
||||||
|
// var template = getTemplateUrl(scope.pageType);
|
||||||
|
// element.html(template);
|
||||||
|
// $compile(element.contents())(scope);
|
||||||
|
// },
|
||||||
|
// controller: function($scope){
|
||||||
|
// console.log('entryPage Controller');
|
||||||
|
// console.log($scope.pageData);
|
||||||
|
// // $scope.exitStartPage = function() {
|
||||||
|
// // if($scope.pageData.showStart) scope.pageData.showStart = false;
|
||||||
|
// // };
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
// }]);
|
|
@ -18,6 +18,7 @@ angular.module('forms').directive('fieldDirective', ['$templateCache', '$http',
|
||||||
var templateUrl = 'modules/forms/views/directiveViews/field/';
|
var templateUrl = 'modules/forms/views/directiveViews/field/';
|
||||||
var supported_fields = [
|
var supported_fields = [
|
||||||
'textfield',
|
'textfield',
|
||||||
|
'welcome_page',
|
||||||
'email',
|
'email',
|
||||||
'textarea',
|
'textarea',
|
||||||
'checkbox',
|
'checkbox',
|
||||||
|
@ -65,6 +66,7 @@ angular.module('forms').directive('fieldDirective', ['$templateCache', '$http',
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// GET template content from path
|
// GET template content from path
|
||||||
|
console.log(scope.field);
|
||||||
var template = getTemplateUrl(scope.field);
|
var template = getTemplateUrl(scope.field);
|
||||||
// $http.get(templateUrl).success(function(data) {
|
// $http.get(templateUrl).success(function(data) {
|
||||||
element.html(template);
|
element.html(template);
|
||||||
|
|
|
@ -16,6 +16,9 @@ angular.module('forms').directive('submitFormDirective', ['$http', '$timeout', '
|
||||||
|
|
||||||
TimeCounter.startClock()
|
TimeCounter.startClock()
|
||||||
|
|
||||||
|
$scope.exitStartPage = function(){
|
||||||
|
$scope.myform.startPage.showStart = false;
|
||||||
|
}
|
||||||
$rootScope.setActiveField = function (field_id) {
|
$rootScope.setActiveField = function (field_id) {
|
||||||
$scope.selected = field_id;
|
$scope.selected = field_id;
|
||||||
};
|
};
|
||||||
|
@ -47,11 +50,6 @@ angular.module('forms').directive('submitFormDirective', ['$http', '$timeout', '
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
$scope.exitStartPage = function () {
|
|
||||||
$scope.myform.startPage.showStart = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.reloadForm = function(){
|
$scope.reloadForm = function(){
|
||||||
//Reset Timer
|
//Reset Timer
|
||||||
TimeCounter.stopClock();
|
TimeCounter.stopClock();
|
||||||
|
|
|
@ -154,7 +154,6 @@
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
beforeEach(inject(function($modal) {
|
beforeEach(inject(function($modal) {
|
||||||
spyOn($modal, 'open').and.returnValue(new fakeModal());
|
spyOn($modal, 'open').and.returnValue(new fakeModal());
|
||||||
}));
|
}));
|
||||||
|
@ -210,7 +209,7 @@
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
// Test scope value
|
// Test scope value
|
||||||
expect( scope.myform.toJSON() ).toEqualData(expectedFormObj.toJSON());
|
expect( scope.myform.toJSON() ).toEqualData(expectedFormObj);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('$scope.removeCurrentForm() with valid form data should send a DELETE request with the id of form', function() {
|
it('$scope.removeCurrentForm() with valid form data should send a DELETE request with the id of form', function() {
|
||||||
|
|
|
@ -0,0 +1,94 @@
|
||||||
|
// 'use strict';
|
||||||
|
|
||||||
|
// (function() {
|
||||||
|
// // Forms Controller Spec
|
||||||
|
// describe('entryPage Directive Tests', function() {
|
||||||
|
// // Initialize global variables
|
||||||
|
// var scope,
|
||||||
|
// $templateCache,
|
||||||
|
// $httpBackend,
|
||||||
|
// $compile;
|
||||||
|
|
||||||
|
// var sampleStartPage = {
|
||||||
|
// showStart: true,
|
||||||
|
// introTitle: 'Welcome to Form',
|
||||||
|
// introParagraph: 'Sample intro paragraph',
|
||||||
|
// buttons:[
|
||||||
|
// {
|
||||||
|
// url: 'http://google.com',
|
||||||
|
// action: '',
|
||||||
|
// text: 'Google',
|
||||||
|
// bgColor: '#ffffff',
|
||||||
|
// color: '#000000',
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// url: 'http://facebook.com',
|
||||||
|
// action: '',
|
||||||
|
// text: 'Facebook',
|
||||||
|
// bgColor: '#0000ff',
|
||||||
|
// color: '#000000',
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
|
// };
|
||||||
|
|
||||||
|
|
||||||
|
// // The $resource service augments the response object with methods for updating and deleting the resource.
|
||||||
|
// // If we were to use the standard toEqual matcher, our tests would fail because the test values would not match
|
||||||
|
// // the responses exactly. To solve the problem, we define a new toEqualData Jasmine matcher.
|
||||||
|
// // When the toEqualData matcher compares two objects, it takes only object properties into
|
||||||
|
// // account and ignores methods.
|
||||||
|
// beforeEach(function() {
|
||||||
|
// jasmine.addMatchers({
|
||||||
|
// toEqualData: function(util, customEqualityTesters) {
|
||||||
|
// return {
|
||||||
|
// compare: function(actual, expected) {
|
||||||
|
// return {
|
||||||
|
// pass: angular.equals(actual, expected)
|
||||||
|
// };
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
|
||||||
|
// // Load the main application module
|
||||||
|
// beforeEach(module(ApplicationConfiguration.applicationModuleName));
|
||||||
|
// beforeEach(module('module-templates'));
|
||||||
|
|
||||||
|
// beforeEach(inject(function($rootScope, _$compile_, _$httpBackend_) {
|
||||||
|
// scope = $rootScope.$new();
|
||||||
|
// $compile = _$compile_;
|
||||||
|
|
||||||
|
// // Point global variables to injected services
|
||||||
|
// $httpBackend = _$httpBackend_;
|
||||||
|
// }));
|
||||||
|
|
||||||
|
|
||||||
|
// it('should be able to render entryPage in html', function() {
|
||||||
|
// scope.myStartPage = _.cloneDeep(sampleStartPage);
|
||||||
|
// console.log(scope.myStartPage);
|
||||||
|
// var element = angular.element('<entry-page pageData="myStartPage" pageType="startPage"></entry-page>');
|
||||||
|
// $compile(element)(scope);
|
||||||
|
// scope.$digest();
|
||||||
|
|
||||||
|
// // console.log(element.html());
|
||||||
|
// expect(element.html()).not.toEqual('<div class="ng-scope">Start Page</div>');
|
||||||
|
// });
|
||||||
|
|
||||||
|
// // it('exitStartPage should work for "startPage" type of entryPage', inject(function($rootScope) {
|
||||||
|
// // scope.myPage = _.cloneDeep(sampleStartPage);
|
||||||
|
// // var el = angular.element('<entry-page pageData="myPage" pageType="startPage"></entry-page>');
|
||||||
|
// // $compile(el)(scope);
|
||||||
|
// // scope.$digest();
|
||||||
|
|
||||||
|
// // $httpBackend.whenGET(/.+\.html$/).respond('');
|
||||||
|
// // $httpBackend.whenGET('/users/me/').respond('');
|
||||||
|
|
||||||
|
// // scope = el.isolateScope() || el.scope();
|
||||||
|
|
||||||
|
// // scope.exitStartPage();
|
||||||
|
// // // expect(scope.myStartPage.showStart).toBe(false);
|
||||||
|
// // expect(el.html()).not.toEqual('<div>Start Page</div>');
|
||||||
|
// // }));
|
||||||
|
// });
|
||||||
|
// }());
|
|
@ -90,9 +90,9 @@
|
||||||
</edit-submissions-form-directive>
|
</edit-submissions-form-directive>
|
||||||
</tab>
|
</tab>
|
||||||
</tabset>
|
</tabset>
|
||||||
<!--
|
<!--
|
||||||
<div class="cg-busy cg-busy-backdrop cg-busy-backdrop-animation ng-show ng-scope"></div> -->
|
<div class="cg-busy cg-busy-backdrop cg-busy-backdrop-animation ng-show ng-scope"></div> -->
|
||||||
<!--
|
<!--
|
||||||
<div class="cg-busy cg-busy-animation cg-busy-default-wrapper">
|
<div class="cg-busy cg-busy-animation cg-busy-default-wrapper">
|
||||||
<div class="cg-busy-default-sign">
|
<div class="cg-busy-default-sign">
|
||||||
<div class="cg-busy-default-spinner">
|
<div class="cg-busy-default-spinner">
|
||||||
|
@ -113,7 +113,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div> -->
|
</div> -->
|
||||||
|
|
||||||
<!-- <div class="cg-busy cg-busy-animation cg-busy-default-wrapper">
|
<!-- <div class="cg-busy cg-busy-animation cg-busy-default-wrapper">
|
||||||
<div style="position: absolute; top: 0px; right: 0px;">
|
<div style="position: absolute; top: 0px; right: 0px;">
|
||||||
<div class="cg-busy-default-spinner">
|
<div class="cg-busy-default-spinner">
|
||||||
<div class="bar1"></div>
|
<div class="bar1"></div>
|
||||||
|
@ -133,7 +133,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div> -->
|
</div> -->
|
||||||
|
|
||||||
<!-- <div class="cg-busy cg-busy-backdrop cg-busy-backdrop-animation ng-show ng-scope"></div>
|
<!-- <div class="cg-busy cg-busy-backdrop cg-busy-backdrop-animation ng-show ng-scope"></div>
|
||||||
<div class="cg-busy cg-busy-animation">
|
<div class="cg-busy cg-busy-animation">
|
||||||
<div style="position: absolute; top: 0px; left: 0px; right: 0px; bottom: 0px;">
|
<div style="position: absolute; top: 0px; left: 0px; right: 0px; bottom: 0px;">
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
<div class="field row text-center">
|
||||||
|
<div class="col-xs-12 text-center">
|
||||||
|
<h1>{{pageData.introTitle}}</h1>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-10 col-xs-offset-1 text-left">
|
||||||
|
<p style="color:#ddd;">{{pageData.introParagraph}}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row form-actions" style="padding-bottom:3em; padding-left: 1em; padding-right: 1em;">
|
||||||
|
<p ng-repeat="button in pageData.buttons" class="text-center" style="display:inline;">
|
||||||
|
<button class="btn btn-info" type="button" ng-style="{'background-color':button.bgColor, 'color':button.color}">
|
||||||
|
<a href="{{button.url}}" style="font-size: 1.6em; text-decoration: none; color: inherit;" >
|
||||||
|
{{button.text}}
|
||||||
|
</a>
|
||||||
|
</button>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="row form-actions">
|
||||||
|
<p class="col-xs-3 col-xs-offset-3 text-center">
|
||||||
|
<button class="btn btn-info" type="button">
|
||||||
|
<a ng-click="exitpageData()" style="color:white; font-size: 1.6em; text-decoration: none;">Continue to Form</a>
|
||||||
|
</button>
|
||||||
|
</p>
|
||||||
|
</div>
|
|
@ -50,16 +50,17 @@
|
||||||
<h4>Preview Start Page</h4>
|
<h4>Preview Start Page</h4>
|
||||||
</div>
|
</div>
|
||||||
<ul class="col-md-12 container" style="list-style:none;border:2px lightgray solid;">
|
<ul class="col-md-12 container" style="list-style:none;border:2px lightgray solid;">
|
||||||
|
<!-- <entryPage pageData="myform.startPage" pageType="startPage"></entryPage> -->
|
||||||
<div class="field row text-center">
|
<div class="field row text-center">
|
||||||
<div class="col-xs-12 text-center">
|
<div class="col-xs-12 text-center">
|
||||||
<h1>{{myform.startPage.introTitle}}</h1>
|
<h1>{{pageData.introTitle}}</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-10 col-xs-offset-1 text-left">
|
<div class="col-xs-10 col-xs-offset-1 text-left">
|
||||||
<p style="color:#ddd;">{{myform.startPage.introParagraph}}</p>
|
<p style="color:#ddd;">{{pageData.introParagraph}}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row form-actions" style="padding-bottom:3em; padding-left: 1em; padding-right: 1em;">
|
<div class="row form-actions" style="padding-bottom:3em; padding-left: 1em; padding-right: 1em;">
|
||||||
<p ng-repeat="button in myform.startPage.buttons" class="text-center" style="display:inline;">
|
<p ng-repeat="button in pageData.buttons" class="text-center" style="display:inline;">
|
||||||
<button class="btn btn-info" type="button" ng-style="{'background-color':button.bgColor, 'color':button.color}">
|
<button class="btn btn-info" type="button" ng-style="{'background-color':button.bgColor, 'color':button.color}">
|
||||||
<a href="{{button.url}}" style="font-size: 1.6em; text-decoration: none; color: inherit;" >
|
<a href="{{button.url}}" style="font-size: 1.6em; text-decoration: none; color: inherit;" >
|
||||||
{{button.text}}
|
{{button.text}}
|
||||||
|
@ -70,7 +71,7 @@
|
||||||
<div class="row form-actions">
|
<div class="row form-actions">
|
||||||
<p class="col-xs-3 col-xs-offset-3 text-center">
|
<p class="col-xs-3 col-xs-offset-3 text-center">
|
||||||
<button class="btn btn-info" type="button">
|
<button class="btn btn-info" type="button">
|
||||||
<a ng-click="exitstartPage()" style="color:white; font-size: 1.6em; text-decoration: none;">Continue to Form</a>
|
<a ng-click="exitpageData()" style="color:white; font-size: 1.6em; text-decoration: none;">Continue to Form</a>
|
||||||
</button>
|
</button>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -5,23 +5,25 @@
|
||||||
<div ng-show="!myform.submitted && myform.startPage.showStart" class="form-submitted">
|
<div ng-show="!myform.submitted && myform.startPage.showStart" class="form-submitted">
|
||||||
<div class="field row text-center">
|
<div class="field row text-center">
|
||||||
<div class="col-xs-12 text-center">
|
<div class="col-xs-12 text-center">
|
||||||
<h1>Welcome to {{myform.title}}</h1>
|
<h1>{{myform.startPage.introTitle}}</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-10 col-xs-offset-1 text-center">
|
<div class="col-xs-10 col-xs-offset-1 text-left">
|
||||||
<p>{{myform.startPage.introText}}</p>
|
<p style="color:#ddd;">{{myform.startPage.introParagraph}}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row form-actions">
|
<div class="row form-actions" style="padding-bottom:3em; padding-left: 1em; padding-right: 1em;">
|
||||||
<p ng-repeat="button in myform.startPage.buttons" class="col-xs-6 col-xs-offset-3 text-center">
|
<p ng-repeat="button in myform.startPage.buttons" class="text-center" style="display:inline;">
|
||||||
<button class="btn btn-info" type="button">
|
<button class="btn btn-info" type="button" ng-style="{'background-color':button.bgColor, 'color':button.color}">
|
||||||
<a href="{{button.url}}" style="font-size: 1.6em; text-decoration: none;">{{button.buttonText}}</a>
|
<a href="{{button.url}}" style="font-size: 1.6em; text-decoration: none; color: inherit;" >
|
||||||
|
{{button.text}}
|
||||||
|
</a>
|
||||||
</button>
|
</button>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="row form-actions">
|
<div class="row form-actions">
|
||||||
<p class="col-xs-6 col-xs-offset-3 text-center">
|
<p class="col-xs-3 col-xs-offset-3 text-center">
|
||||||
<button class="btn btn-info" type="button">
|
<button class="btn btn-info" type="button">
|
||||||
<a ng-click="exitStartPage()" style="font-size: 1.6em; text-decoration: none;">Continue to Form</a>
|
<a ng-click="exitStartPage()" style="color:white; font-size: 1.6em; text-decoration: none;">Continue to Form</a>
|
||||||
</button>
|
</button>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -36,6 +36,8 @@ angular.module('users').controller('AuthenticationController', ['$scope', '$loca
|
||||||
$state.go('signup-success');
|
$state.go('signup-success');
|
||||||
},
|
},
|
||||||
function(error) {
|
function(error) {
|
||||||
|
console.log('Error: ');
|
||||||
|
console.log(error);
|
||||||
if(error) {
|
if(error) {
|
||||||
$scope.error = error;
|
$scope.error = error;
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
|
Loading…
Reference in a new issue