-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.js
35 lines (32 loc) · 914 Bytes
/
helpers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var moment = require('moment')
, mongoose = require('mongoose');
exports.staticHelpers = {
};
exports.dynamicHelpers = {
errorMessages: function(req, res){
},
flashMessages: function(app) {
var html = '';
['error', 'question', 'info', 'success'].forEach(function(type) {
var messages = app.req.flash(type);
if (messages.length > 0) {
messages.forEach(function(message){
html += '<div class="alert alert-block alert-'+(type == 'info' ? 'warning' : (type == 'question' ? 'error' : type))+' fade in"><a class="close" data-dismiss="alert" href="#">×</a>'+message+'</div>';
});
}
});
return html;
}
, user: function(app, minimumState){
if(minimumState == undefined){
minimumState = 0
}
if(app.req.user && app.req.user.state >= minimumState){
return app.req.user;
}
}
, authServer: function(){
return process.env.AUTH_SERVER;
}
/* , moment: moment */
};