-
Notifications
You must be signed in to change notification settings - Fork 7
/
routes.js
58 lines (45 loc) · 1.47 KB
/
routes.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
'use strict';
module.exports = function (args) {
var app = args.app;
var opts = args.options;
var userpin = args.seneca.pin({role:'user',cmd:'*'});
require('./lib/oauth2-routes')(args);
function render(res, pageName) {
var page = (opts.theme && opts.theme.page && opts.theme.page[pageName]) ? opts.theme.page[pageName] : pageName;
res.render(page);
}
// Upload files
app.post('/upload', function(req, res) {
res.end(JSON.stringify({url:'/uploads/' + req.files.file.path.split('/').pop()}));
});
app.get('/', function(req, res) {
render(res, 'index');
});
app.get('/account', function(req, res) {
render(res, 'account');
});
// let the user enter an email and submit a post to reset -> /auth/create_reset {"email": "[email protected]"}
app.get('/reset', function(req, res) {
render(res, 'reset');
});
// accept the reset link and show password reset form which gets posted to /auth/execute_reset
app.get('/reset/:token', function(req, res) {
userpin.load_reset({
token: req.params.token
}, function (err, out) {
res.render('reset_request', {tokenInfo: {ok: out.ok, why: out.why, token: req.params.token}});
});
});
app.use( function( req, res, next ){
if( 0 === req.url.indexOf('/signup') ||
0 === req.url.indexOf('/forgot') ||
0 === req.url.indexOf('/confirm') ||
0 === req.url.indexOf('/doconfirm'))
{
render(res, 'index');
}
else {
next();
}
});
};