forked from meanjs/mean
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore.server.controller.js
More file actions
63 lines (57 loc) · 1.62 KB
/
Copy pathcore.server.controller.js
File metadata and controls
63 lines (57 loc) · 1.62 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
'use strict';
var validator = require('validator'),
path = require('path'),
config = require(path.resolve('./config/config'));
/**
* Render the main application page
*/
exports.renderIndex = function (req, res) {
var safeUserObject = null;
if (req.user) {
safeUserObject = {
displayName: validator.escape(req.user.displayName),
provider: validator.escape(req.user.provider),
username: validator.escape(req.user.username),
created: req.user.created.toString(),
roles: req.user.roles,
profileImageURL: req.user.profileImageURL,
email: validator.escape(req.user.email),
lastName: validator.escape(req.user.lastName),
firstName: validator.escape(req.user.firstName),
additionalProvidersData: req.user.additionalProvidersData
};
}
res.render('modules/core/server/views/index', {
user: JSON.stringify(safeUserObject),
sharedConfig: JSON.stringify(config.shared)
});
};
/**
* Render the server error page
*/
exports.renderServerError = function (req, res) {
res.status(500).render('modules/core/server/views/500', {
error: 'Oops! Something went wrong...'
});
};
/**
* Render the server not found responses
* Performs content-negotiation on the Accept HTTP header
*/
exports.renderNotFound = function (req, res) {
res.status(404).format({
'text/html': function () {
res.render('modules/core/server/views/404', {
url: req.originalUrl
});
},
'application/json': function () {
res.json({
error: 'Path not found'
});
},
'default': function () {
res.send('Path not found');
}
});
};