fixed signup error

This commit is contained in:
David Baldwynn 2016-08-17 12:04:42 -07:00
parent b4923dda4c
commit de5ac881c9
16 changed files with 161 additions and 124 deletions

5
.gitignore vendored
View file

@ -78,3 +78,8 @@ build/
coverage/
coverageServer/
coverageClient/
# Elastic Beanstalk Files
.elasticbeanstalk/*
!.elasticbeanstalk/*.cfg.yml
!.elasticbeanstalk/*.global.yml

View file

@ -1,16 +1,74 @@
# DOCKER-VERSION 1.7.0
# Build:
# docker build -t meanjs/mean .
#
# Run:
# docker run -it meanjs/mean
#
# Compose:
# docker-compose up -d
FROM node:4
FROM ubuntu:latest
MAINTAINER David Baldwynn <team@tellform.com>
WORKDIR /usr/src/app
WORKDIR ~/Documents/tellform
# Install Mean.JS Prerequisites
RUN npm install -g grunt-cli bower
# Install Utilities
RUN apt-get update -q
RUN apt-get install -yqq python wget aptitude htop vim git traceroute dnsutils curl ssh sudo tree tcpdump nano psmisc gcc make build-essential libfreetype6 libfontconfig libkrb5-dev
# currently only works for development
ENV python /usr/bin/python
# Install gem sass for grunt-contrib-sass
RUN apt-get install -y ruby
RUN gem install sass
# Install NodeJS
RUN curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
RUN sudo apt-get install -yq nodejs
# Install MEAN.JS Prerequisites
RUN npm install --quiet -g grunt-cli gulp bower mocha karma-cli pm2
RUN mkdir /opt/mean.js
RUN mkdir -p /opt/mean.js/public/lib
WORKDIR /opt/mean.js
# Copies the local package.json file to the container
# and utilities docker container cache to not needing to rebuild
# and install node_modules/ everytime we build the docker, but only
# when the local package.json file changes.
# Install npm packages
ADD package.json /opt/mean.js/package.json
RUN npm install --quiet
# Install bower packages
ADD bower.json /opt/mean.js/bower.json
ADD .bowerrc /opt/mean.js/.bowerrc
RUN bower install --quiet --allow-root --config.interactive=false
# Share local directory on the docker container
ADD . /opt/mean.js
# Machine cleanup
RUN npm cache clean
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Set development environment as default
ENV NODE_ENV development
# Port 3000 for server
# Ports generic
EXPOSE 80:80
EXPOSE 443:443
# Port 3000 for MEAN.JS server
EXPOSE 3000:3000
# Port 5858 for node debug
EXPOSE 5858:5858
# Port 35729 for livereload
EXPOSE 3000 35729
CMD ["grunt"]
EXPOSE 35729:35729
# Run MEAN.JS server
CMD ["npm", "start"]

View file

@ -99,46 +99,46 @@ exports.resendVerificationEmail = function(req, res, next){
* Signup
*/
exports.signup = function(req, res) {
// For security measures we remove the roles from the req.body object
delete req.body.roles;
delete req.body.roles;
// Init Variables
var user = new User(req.body);
// Init Variables
var user = new User(req.body);
// Add missing user fields
user.provider = 'local';
// Add missing user fields
user.provider = 'local';
// Then save the temporary user
nev.createTempUser(user, function (err, newTempUser) {
// Then save the temporary user
nev.createTempUser(user, function (err, existingPersistentUser, newTempUser) {
debugger;
if (err) {
console.log('Error: ');
console.log(err);
return res.status(400).send({
message: errorHandler.getErrorMessage(err)
});
}
if (err) {
console.log('Error: ');
console.log(err);
return res.status(400).send({
message: errorHandler.getErrorMessage(err)
});
} else {
// new user created
if (newTempUser) {
var URL = newTempUser[nev.options.URLFieldName];
nev.sendVerificationEmail(user.email, URL, function (err, info) {
if (err) {
console.log('Error: ');
console.log(err);
return res.status(400).send({
message: errorHandler.getErrorMessage(err)
});
} else {
return res.status(200).send('An email has been sent to you. Please check it to verify your account.');
}
// new user created
if (newTempUser) {
var URL = newTempUser[nev.options.URLFieldName];
nev.sendVerificationEmail(user.email, URL, function (err, info) {
if (err) {
console.log('Error: ');
console.log(err);
return res.status(400).send({
message: errorHandler.getErrorMessage(err)
});
} else {
console.log('Error: User already exists!');
return res.status(400).send({message: 'Error: User already exists!'});
return res.status(200).send('An email has been sent to you. Please check it to verify your account.');
}
}
});
});
} else {
console.log('Error: User already exists!');
return res.status(400).send({message: 'Error: User already exists!'});
}
});
};
/**

View file

@ -127,6 +127,7 @@ function BaseFieldSchema(){
'hidden',
'yes_no',
'natural',
'stripe',
'number'
]
},

View file

@ -12,8 +12,6 @@ var should = require('should'),
config = require('../../config/config'),
FormSubmission = mongoose.model('FormSubmission');
var exampleDemo = {
activeCount: 1,
DOB: '',

View file

@ -19,10 +19,10 @@
"angular-ui-router": "~0.2.11",
"ng-file-upload": "^12.0.4",
"angular-raven": "~0.5.11",
"angular-ui-date": "~0.0.8",
"angular-ui-date": "~0.0.11",
"lodash": "~3.10.0",
"angular-ui-sortable": "~0.13.4",
"angular-permission": "~1.1.0",
"angular-permission": "~1.1.1",
"file-saver.js": "~1.20150507.2",
"angular-bootstrap-colorpicker": "~3.0.19",
"angular-ui-router-tabs": "~1.7.0",
@ -34,9 +34,9 @@
"raven-js": "^3.0.4",
"tableExport.jquery.plugin": "^1.5.1",
"js-yaml": "^3.6.1",
"angular-ui-select": "whitef0x0/ui-select#compiled",
"angular-ui-select": "https://github.com/whitef0x0/ui-select.git#compiled",
"angular-translate": "~2.11.0",
"ng-device-detector": "^3.0.1",
"ng-device-detector": "~3.0.1",
"ng-translate": "*"
},
"resolutions": {

View file

@ -121,7 +121,6 @@ module.exports = function(db) {
next();
});
});
//Setup Prerender.io

View file

@ -1,29 +1,24 @@
version: '2'
services:
db:
image: mongo:3.2
ports:
- "27017:27017"
volumes:
- mongo-data-wt:/data/db
redis:
image: redis
web:
build: .
volumes:
- .:/usr/src/app
command: node server.js
ports:
- "3000:3000"
- "35729:35729"
links:
- db
- redis
environment:
DB_HOST: db
REDIS_HOST: redis
volumes:
mongo-data-wt:
driver: local
web:
restart: always
build: .
container_name: tellform
command: npm start
links:
- db
ports:
- "3000:3000"
- "5858:5858"
- "35729:35729"
environment:
- NODE_ENV=development
volumes:
- ./:/opt/mean.js
- /opt/mean.js/node_modules
- /opt/mean.js/public
- /opt/mean.js/uploads
db:
image: mongo:3.2
container_name: db_1
restart: always
ports:
- "27017:27017"

View file

@ -30,6 +30,7 @@
"bower": "~1.6.5",
"chalk": "^1.1.3",
"compression": "~1.6.0",
"connect": "^3.4.1",
"connect-flash": "~0.1.1",
"connect-mongo": "~0.8.2",
"consolidate": "~0.13.1",
@ -71,6 +72,7 @@
"multer": "~1.1.0",
"node-freegeoip": "0.0.1",
"nodemailer": "~1.10.0",
"nodemailer-sparkpost-transport": "^1.0.0",
"passport": "~0.3.0",
"passport-anonymous": "^1.0.1",
"passport-facebook": "~2.0.0",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,27 +0,0 @@
<div class="field row dropdown" ng-click="setActiveField(field._id, index, true)" ng-if="field.fieldOptions.length > 0">
<div class="col-xs-12 field-title" ng-style="{'color': design.colors.questionColor}">
<h3>
<span class="fa fa-angle-double-right"></span>
{{field.title}}
<span class="required-error" ng-show="!field.required">{{ 'OPTIONAL' | translate }}</span>
</h3>
</div>
<div class="col-xs-12 field-input ">
<ui-select ng-model="field.fieldValue"
theme="selectize"
ng-model-options="{ debounce: 250 }"
ng-required="field.required"
ng-disabled="field.disabled"
ng-focus="setActiveField(field._id, index, true)">
<ui-select-match placeholder="Type or select an option">
{{$select.selected.option_value}}
</ui-select-match>
<ui-select-choices
repeat="option in field.fieldOptions | filter: $select.search"
ng-class="{'active': option.option_value === field.fieldValue }">
<span ng-bind-html="option.option_value | highlight: $select.search"></span>
</ui-select-choices>
</ui-select>
</div>
</div>
<br>

View file

@ -16,7 +16,7 @@ angular.module('users').config(['$translateProvider', function ($translateProvid
EMAIL_LABEL: 'Email',
SIGNUP_HEADER_TEXT: 'Sign up with your email',
SIGNIN_HEADER_TEXT: 'Signup in with your email',
SIGNIN_HEADER_TEXT: 'Sign in with your email or username',
SIGNUP_ERROR_TEXT: 'Couldn\'t complete registration due to errors',

View file

@ -165,6 +165,11 @@ var questions = [
name: 'email',
message: 'What should be the email for your admin account?'
},
{
type: 'input',
name: 'username',
message: 'What should be the username for your admin account?'
},
{
type: 'password',
name: 'password',
@ -175,7 +180,7 @@ var questions = [
if(!fs.existsSync('./\.env')) {
console.log(chalk.green('\n\nHi, welcome to TellForm Setup'));
console.log(chalk.green('You should only run this the first time you setup TellForm\n--------------------------------------------------\n\n'));
console.log(chalk.green('You should only run this the first time you run TellForm\n--------------------------------------------------\n\n'));
inquirer.prompt([questions[0]]).then(function (confirmAns) {
if (confirmAns['shouldContinue']) {
@ -185,6 +190,7 @@ if(!fs.existsSync('./\.env')) {
answers['SIGNUP_DISABLED'] = false ? answers['SIGNUP_DISABLED'] === false : true;
var email = answers['email'];
var username = answers['email'];
var pass = answers['password'];
delete answers['email'];
delete answers['password'];
@ -198,7 +204,7 @@ if(!fs.existsSync('./\.env')) {
firstName: 'Admin',
lastName: 'Account',
email: email,
username: email,
username: username,
password: pass,
provider: 'local',
roles: ['admin', 'user']