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
64
|
module.exports = function(app) {
/*
* GET home page.
*
* '/'
*/
app.get('/', function(req, res){
// check if the user's credentials are saved in a cookie
if (req.cookies.user == undefined || req.cookies.pass == undefined) {
res.render('index', { title: 'DERS' });
} else { // appempt automatic login
AM.autoLogin(req.cookies.user, req.cookies.pass, function(o) {
if (o != null) {
req.session.user = o;
res.redirect('/account');
} else {
res.render('index', { title: 'DERS' });
}
});
}
});
/*
* GET login page
*
* '/login'
*/
app.get('/login', function(req, res) {
res.render('login', { title: 'Logg inn' });
});
/*
* 404 ERROR
*/
app.get('*', function(req, res) {
res.render('error', { title: '404', text: 'Fant ikke siden' });
});
}
|