-
Notifications
You must be signed in to change notification settings - Fork 1
/
routes.js
53 lines (48 loc) · 2.55 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
module.exports = function(app,passport){
/**
* Controllers (route handlers).
*/
const homeController = require('./controllers/home');
const userController = require('./controllers/user');
const contactController = require('./controllers/contact');
const dashboardController = require('./controllers/dashboard');
/**
* API keys and Passport configuration.
*/
const passportConfig = require('./config/passport');
/**
* Primary app routes.
*/
app.get('/', homeController.index);
app.get('/about', homeController.about);
app.get('/login', userController.getLogin);
app.post('/login', userController.postLogin);
app.get('/logout', userController.logout);
app.get('/forgot', userController.getForgot);
app.post('/forgot', userController.postForgot);
app.get('/reset/:token', userController.getReset);
app.post('/reset/:token', userController.postReset);
app.get('/signup', userController.getSignup);
app.post('/signup', userController.postSignup);
app.get('/contact', contactController.getContact);
app.post('/contact', contactController.postContact);
app.get('/account', passportConfig.isAuthenticated, userController.getAccount);
app.post('/account/profile', passportConfig.isAuthenticated, userController.postUpdateProfile);
app.post('/account/password', passportConfig.isAuthenticated, userController.postUpdatePassword);
app.post('/account/delete', passportConfig.isAuthenticated, userController.postDeleteAccount);
app.get('/account/unlink/:provider', passportConfig.isAuthenticated, userController.getOauthUnlink);
/**
* OAuth authentication routes. (Sign in)
*/
app.get('/auth/facebook', passport.authenticate('facebook', { scope: ['email', 'user_location'] }));
app.get('/auth/facebook/callback', passport.authenticate('facebook', { failureRedirect: '/login' }), (req, res) => {
res.redirect('/dashboard');
});
app.get('/auth/google', passport.authenticate('google', { scope: 'profile email' }));
app.get('/auth/google/callback', passport.authenticate('google', { failureRedirect: '/login' }), (req, res) => {
res.redirect('/dashboard');
});
app.get("/dashboard",passportConfig.isAuthenticated,dashboardController.getDashboard );
app.get("/dashboard/measurements/export/:deviceId",passportConfig.isAuthenticated,dashboardController.getFileWithMeasurementsInfo);
app.get("/dashboard/measurements/:deviceId/hours/:hours",passportConfig.isAuthenticated,dashboardController.getMeasurementsForDevice);
}