Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #34

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Dev #34

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,25 @@
"homepage": "http://meanjs.org/",
"license": "MIT",
"dependencies": {
"bootstrap": "^3.3.7",
"angular": "~1.3",
"angular-resource": "~1.3",
"angular-animate": "~1.3",
"angular-mocks": "~1.3",
"angular-bootstrap": "~0.13",
"angular-ui-utils": "bower",
"angular-ui-router": "~0.2",
"angular-file-upload": "1.1.5",
"angular-messages": "~1.3.17",
"bootstrap": "^4.0.0",
"angular": "~1.8.0",
"angular-resource": "~1.8.0",
"angular-cache": "4.6.0",
"angular-animate": "~1.8.0",
"angular-mocks": "~1.8.0",
"angular-bootstrap": "~2.5.0",
"angular-ui-utils": "3.0.0",
"angular-ui-router": "~1.0.26",
"angular-file-upload": "2.6.0",
"angular-messages": "~1.8.0",
"owasp-password-strength-test": "~1.3.0",
"eonasdan-bootstrap-datetimepicker": "~4.17.37",
"ngSweetAlert": "angular-sweetalert#^1.1.0",
"angular-formly": "^8.4.0",
"angular-formly-templates-bootstrap": "^6.3.2",
"eonasdan-bootstrap-datetimepicker": "~4.17.47",
"ngSweetAlert": "angular-sweetalert#^1.1.3",
"angular-formly": "^8.4.1",
"angular-formly-templates-bootstrap": "^6.2.0",
"api-check": "^7.5.5",
"angularjs-slider": "^5.9.0",
"angular-ui-select": "^0.19.6"
"angularjs-slider": "^7.0.0",
"angular-ui-select": "^0.19.8"
},
"resolutions": {
"angular": "~1.3"
Expand Down
58 changes: 29 additions & 29 deletions config/assets/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,38 @@ module.exports = {
client: {
lib: {
css: [
'public/lib/bootstrap/dist/css/bootstrap.css',
'public/lib/bootstrap/dist/css/bootstrap-theme.css',
'public/lib/angular-bootstrap/ui-bootstrap-csp.js',
'public/lib/angularjs-slider/dist/rzslider.css',
'public/lib/sweetalert/dist/sweetalert.css',
'public/lib/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css'
'node_modules/@bower_components/bootstrap/dist/css/bootstrap.css',
'node_modules/@bower_components/bootstrap/dist/css/bootstrap-theme.css',
'node_modules/@bower_components/angular-bootstrap/ui-bootstrap-csp.js',
'node_modules/@bower_components/angularjs-slider/dist/rzslider.css',
'node_modules/@bower_components/sweetalert/dist/sweetalert.css',
'node_modules/@bower_components/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css'
],
js: [
'public/lib/api-check/dist/api-check.js',
'public/lib/jquery/dist/jquery.min.js',
'public/lib/bootstrap/dist/js/bootstrap.min.js',
'public/lib/angular/angular.js',
'public/lib/angular-formly/dist/formly.js',
'public/lib/angular-formly-templates-bootstrap/dist/angular-formly-templates-bootstrap.js',
'public/lib/angularjs-slider/dist/rzslider.js',
'public/lib/angular-resource/angular-resource.js',
'public/lib/angular-animate/angular-animate.js',
'public/lib/angular-messages/angular-messages.js',
'public/lib/angular-ui-router/release/angular-ui-router.js',
'public/lib/angular-ui-utils/ui-utils.js',
'public/lib/angular-file-upload/angular-file-upload.js',
'public/lib/angular-cache/dist/angular-cache.js',
'public/lib/q/q.js',
'public/lib/owasp-password-strength-test/owasp-password-strength-test.js',
'public/lib/angular-bootstrap/ui-bootstrap.min.js',
'public/lib/angular-bootstrap/ui-bootstrap-tpls.min.js',
'public/lib/moment/min/moment.min.js',
'public/lib/sweetalert/dist/sweetalert.min.js',
'public/lib/ngSweetAlert/SweetAlert.min.js',
'public/lib/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js'
'node_modules/@bower_components/api-check/dist/api-check.js',
'node_modules/@bower_components/jquery/dist/jquery.min.js',
'node_modules/@bower_components/bootstrap/dist/js/bootstrap.min.js',
'node_modules/@bower_components/angular/angular.js',
'node_modules/@bower_components/angular-formly/dist/formly.js',
'node_modules/@bower_components/angular-formly-templates-bootstrap/dist/angular-formly-templates-bootstrap.js',
'node_modules/@bower_components/angularjs-slider/dist/rzslider.js',
'node_modules/@bower_components/angular-resource/angular-resource.js',
'node_modules/@bower_components/angular-animate/angular-animate.js',
'node_modules/@bower_components/angular-messages/angular-messages.js',
'node_modules/@bower_components/angular-ui-router/release/angular-ui-router.js',
'node_modules/@bower_components/angular-ui-utils/ui-utils.js',
'node_modules/@bower_components/angular-file-upload/dist/angular-file-upload.js',
'node_modules/@bower_components/angular-cache/dist/angular-cache.js',
'node_modules/@bower_componentsb/q/q.js',
'node_modules/@bower_components/owasp-password-strength-test/owasp-password-strength-test.js',
'node_modules/@bower_components/angular-bootstrap/ui-bootstrap.min.js',
'node_modules/@bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js',
'node_modules/@bower_components/moment/min/moment.min.js',
'node_modules/@bower_components/sweetalert/dist/sweetalert.min.js',
'node_modules/@bower_components/ngSweetAlert/SweetAlert.min.js',
'node_modules/@bower_components/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js'
],
tests: ['public/lib/angular-mocks/angular-mocks.js']
tests: ['node_modules/@bower_components/angular-mocks/angular-mocks.js']
},
css: [
'modules/*/client/css/*.css'
Expand Down
2 changes: 1 addition & 1 deletion config/env/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ module.exports = {
}
},
seedDB: {
seed: process.env.MONGO_SEED === 'true' ? true : false,
seed: true,//process.env.MONGO_SEED === 'true' ? true : false,
options: {
logResults: process.env.MONGO_SEED_LOG_RESULTS === 'false' ? false : true,
seedUser: {
Expand Down
1 change: 1 addition & 0 deletions config/env/test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

'use strict';

var defaultEnvConfig = require('./default');
Expand Down
109 changes: 55 additions & 54 deletions config/lib/app.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,55 @@
'use strict';
/**
* Module dependencies.
*/
var config = require('../config'),
mongoose = require('./mongoose'),
express = require('./express'),
seed = require('./seed'),
chalk = require('chalk');

function seedDB() {
if (config.seedDB && config.seedDB.seed) {
console.log(chalk.bold.red('Warning: Database seeding is turned on'));
seed.start();
}
}

// Initialize Models
mongoose.loadModels(seedDB);
module.exports.loadModels = function loadModels() {
mongoose.loadModels();
};

module.exports.init = function init(callback) {
mongoose.connect(function (db) {
// Initialize express
var app = express.init(db);
if (callback) callback(app, db, config);
});
};

module.exports.start = function start(callback) {
var _this = this;
_this.init(function (app, db, config) {
// Start the app by listening on <port>
app.listen(config.port, config.bindIp, function () {
// Logging initialization
console.log('--');
console.log(chalk.green(config.app.title));
console.log(chalk.green('Environment:\t\t\t' + process.env.NODE_ENV));
console.log(chalk.green('Port:\t\t\t\t' + config.port));
console.log(chalk.green('Database:\t\t\t\t' + config.db.uri));
if (process.env.NODE_ENV === 'secure') {
console.log(chalk.green('HTTPs:\t\t\t\ton'));
}
console.log(chalk.green('App version:\t\t\t' + config.meanjs.version));
if (config.meanjs['meanjs-version']) console.log(chalk.green(
'MEAN.JS version:\t\t\t' + config.meanjs['meanjs-version']
));
console.log('--');
if (callback) callback(app, db, config);
});
});
};
'use strict';

/**
* Module dependencies.
*/
var config = require('../config'),
mongoose = require('./mongoose'),
express = require('./express'),
seed = require('./seed'),
chalk = require('chalk');

function seedDB() {
if (config.seedDB && config.seedDB.seed) {
console.log(chalk.bold.red('Warning: Database seeding is turned on'));
seed.start();
}
}

// Initialize Models
mongoose.loadModels(seedDB);
module.exports.loadModels = function loadModels() {
mongoose.loadModels();
};

module.exports.init = function init(callback) {
mongoose.connect(function (db) {
// Initialize express
let app = express.init(db);
if (callback) callback(app, db, config);
});
};

module.exports.start = function start(callback) {
let _this = this;
_this.init(function (app, db, config) {
// Start the app by listening on <port>
app.listen(config.port, config.bindIp, function () {
// Logging initialization
console.log('--');
console.log(chalk.green(config.app.title));
console.log(chalk.green('Environment:\t\t\t' + process.env.NODE_ENV));
console.log(chalk.green('Port:\t\t\t\t' + config.port));
console.log(chalk.green('Database:\t\t\t\t' + config.db.uri));
if (process.env.NODE_ENV === 'secure') {
console.log(chalk.green('HTTPs:\t\t\t\ton'));
}
console.log(chalk.green('App version:\t\t\t' + config.meanjs.version));
if (config.meanjs['meanjs-version']) console.log(chalk.green(
'MEAN.JS version:\t\t\t' + config.meanjs['meanjs-version']
));
console.log('--');
if (callback) callback(app, db, config);
});
});
};
5 changes: 4 additions & 1 deletion config/lib/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ module.exports.initMiddleware = function (app) {
app.locals.cache = 'memory';
}

app.use(express.static('./users/client/img/profile/uploads/'));

// Request body parsing middleware should be above methodOverride
app.use(bodyParser.urlencoded({
extended: true
Expand Down Expand Up @@ -112,6 +114,7 @@ module.exports.initViewEngine = function (app) {
*/
module.exports.initSession = function (app, db) {
// Express MongoDB session storage
console.log(config.db.uri);
app.use(session({
saveUninitialized: true,
resave: true,
Expand Down Expand Up @@ -233,7 +236,7 @@ module.exports.init = function (db) {

// Initialize Express view engine
this.initViewEngine(app);

// Initialize Helmet security headers
this.initHelmetHeaders(app);

Expand Down
4 changes: 2 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ gulp.task('env:dev', function () {
gulp.task('env:prod', function () {
process.env.NODE_ENV = 'production';
});
// Nodemon task
// Nodemon task -- updated --debug arg to --inspect (deprecated)
gulp.task('nodemon', function () {
return plugins.nodemon({
script: 'server.js',
nodeArgs: ['--debug'],
nodeArgs: ['--inspect'],
ext: 'js,html',
watch: _.union(defaultAssets.server.views, defaultAssets.server.allJS, defaultAssets.server.config)
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ angular.module('ctfEvents').controller('CreateEventsController', ['$scope', '$co
});

CtfEvents.save(ctfEvent, function (response) {
$scope.socket.emit('invalidate', { id: response._id })
$scope.socket.emit('invalidate', { id: response.data._id })
$scope.socket.emit('invalidateAll')
CtfEvents.get({ ctfEventId: response._id }).$promise.then(function (data) { console.info('grabbed ' + data) })
$location.path('ctfEvents/' + response._id);
CtfEvents.get({ ctfEventId: response.data._id }).$promise.then(function (data) { console.info('grabbed ' + data) })
$location.path('/ctfEvents/dash/' + response.data._id);
}, function (errorResponse) {
$scope.error = errorResponse.data.message;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,20 @@ angular.module('ctfEvents').controller('ListEventsController', ['$state', '$scop
* Determines whether or not a user is registered for an event
*/
$scope.isRegistered = function (ctfEvent) {
return ctfEvent.users.indexOf(Authentication.user._id) > -1 ? 'ctfEvents.dashboard({ ctfEventId : ctfEvent._id })' : '-'
return ctfEvent.users.indexOf(Authentication.user._id) > -1 ? 'ctfEvents.dashboard({ ctfEventId : ctfEvent._id })' : 'false'
}

/*
* Determines whether or not a user can register for an event
* --Update: stupid hack to actually get this working, wasn't before. Not sure why the HTML boolean recognition is so wack,
* but it's reading the hide as show, and nothing as hide :/
*/
$scope.canRegister = function (ctfEvent) {
return ctfEvent.registrationStart < moment().format('YYYY-MM-DDTHH:mm:ss.SSS[Z]') && moment().format('YYYY-MM-DDTHH:mm:ss.SSS[Z]') < ctfEvent.registrationEnd
if((ctfEvent.registrationStart < moment().format('YYYY-MM-DDTHH:mm:ss.SSS[Z]')) && ((moment().format('YYYY-MM-DDTHH:mm:ss.SSS[Z]') < ctfEvent.registrationEnd) || (!ctfEvent.registrationEnd)) && (ctfEvent.users.indexOf(Authentication.user._id) <= -1)) {
return 'ng-hide';
} else {
return '';
}
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ <h1>Upcoming Events
</div>
<div class="list-group">
<a ng-repeat="ctfEvent in ctfEvents" ui-sref="{{isRegistered(ctfEvent)}}"
ng-class="isRegistered(ctfEvent) === '-' ? 'list-group-item disabled' : 'list-group-item'">
ng-class="isRegistered(ctfEvent) === 'false' ? 'list-group-item disabled' : 'list-group-item'">
<small class="list-group-item-text">
Created on
<span ng-bind="ctfEvent.created | date:'mediumDate'"></span>
</small>
<div class="pull-right">
<button class='btn btn-success' ng-show="isRegistered(ctfEvent) === '-' && canRegister(ctfEvent)" ng-click="registerForEvent(ctfEvent._id)">
<button class='btn btn-success' ng-show="canRegister(ctfEvent)" ng-click="registerForEvent(ctfEvent._id)">
<i class="fa fa-pencil-square-o"></i>register</button>
</div>
<h4 class="list-group-item-heading" ng-bind="ctfEvent.title"></h4>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var path = require('path'),
errorHandler = require(path.resolve('./modules/core/server/controllers/errors.server.controller'));

exports.create = function (req, res) {
var ctfEvent = new CtfEvent(req.body.answers);
var ctfEvent = new CtfEvent(req.body);
ctfEvent.save(function (err) {
if (err) {
return res.status(400).send({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ angular.module('teams')
})
angular.forEach($scope.users, function (user) {
if (user._id === message._id) {
user.joinRequestsFromUsers.push(message._id);
user.requestedToJoin.push(message._id);
}
})
});
Expand Down
Loading