Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. $routeProvider.
  2. when('/categoryview', {
  3. templateUrl: 'templates/partials/app/categoryview/CategoryView.html',
  4. controller: 'ApplicationController'
  5. }).
  6. when('/:categoryId/themes', {
  7. templateUrl: 'templates/partials/app/themeview/ThemeView.html',
  8. controller: 'ThemeViewController'
  9. })
  10. .otherwise({redirectTo: '/categoryview'});
  11.  
  12. module.exports = function(app, passport) {
  13. // route for home page
  14. app.get('/', function(req, res) {
  15. res.redirect('/login');
  16. });
  17. //Route for login to present the login page back to user
  18. app.get('/login', function(req, res) {
  19. res.set({'content-type': 'text/html; charset=utf-8'})
  20. res.render('login.ejs', {message: req.flash('loginMessage')})
  21. });
  22.  
  23. //Route to get the username and password and authenticate
  24. app.post('/authenticate', passport.authenticate('local-login', {
  25. successRedirect: '/themelibrary', // redirect to the secure themelibrary section
  26. failureRedirect: '/login', // redirect back to the signup page if there is an error
  27. failureFlash: true // allow flash messages
  28. }));
  29.  
  30. // route for default lending page
  31. app.get('/themelibrary', isLoggedIn, function(req, res) {
  32. var url= require('url');
  33. console.log("themelibrary hash url >> " + url.hash);
  34. res.charset = 'utf8';
  35. res.set({'content-type': 'text/html; charset=utf-8'})
  36. res.render('index.ejs', {
  37. user: req.user
  38. // get the user out of session and pass to template
  39. });
  40. });
  41.  
  42. // route middleware to make sure a user is logged in
  43. function isLoggedIn(req, res, next) {
  44. // if user is authenticated in the session, carry on
  45. if (req.isAuthenticated())
  46. return next();
  47. // if they aren't redirect them to the home page
  48. res.redirect('/');
  49. }
  50.  
  51. module.exports = function(app) {
  52. app.get('/users/:id', userService.getUserById);
  53. app.get('/users', userService.getAllUsers);
  54. app.post('/themes', themeService.addTheme);
  55. app.get('/themes/:id', themeService.getThemeById);
  56. app.put('/themes/:id', themeService.updateTheme);
  57. app.delete('/themes/:id', themeService.deleteTheme);
  58. app.get('/themes', themeService.getThemes);
  59. app.get('/resources/:code', languageResourceService.getLanguageResourceByCode);
  60. app.get('/config', applicationConfigService.getApplicationConfig);
  61. app.post('/keepalive', applicationConfigService.keepAlive);
  62. app.get('/categories', categoryService.getAllCategories);
  63. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement