Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $routeProvider.
- when('/categoryview', {
- templateUrl: 'templates/partials/app/categoryview/CategoryView.html',
- controller: 'ApplicationController'
- }).
- when('/:categoryId/themes', {
- templateUrl: 'templates/partials/app/themeview/ThemeView.html',
- controller: 'ThemeViewController'
- })
- .otherwise({redirectTo: '/categoryview'});
- module.exports = function(app, passport) {
- // route for home page
- app.get('/', function(req, res) {
- res.redirect('/login');
- });
- //Route for login to present the login page back to user
- app.get('/login', function(req, res) {
- res.set({'content-type': 'text/html; charset=utf-8'})
- res.render('login.ejs', {message: req.flash('loginMessage')})
- });
- //Route to get the username and password and authenticate
- app.post('/authenticate', passport.authenticate('local-login', {
- successRedirect: '/themelibrary', // redirect to the secure themelibrary section
- failureRedirect: '/login', // redirect back to the signup page if there is an error
- failureFlash: true // allow flash messages
- }));
- // route for default lending page
- app.get('/themelibrary', isLoggedIn, function(req, res) {
- var url= require('url');
- console.log("themelibrary hash url >> " + url.hash);
- res.charset = 'utf8';
- res.set({'content-type': 'text/html; charset=utf-8'})
- res.render('index.ejs', {
- user: req.user
- // get the user out of session and pass to template
- });
- });
- // route middleware to make sure a user is logged in
- function isLoggedIn(req, res, next) {
- // if user is authenticated in the session, carry on
- if (req.isAuthenticated())
- return next();
- // if they aren't redirect them to the home page
- res.redirect('/');
- }
- module.exports = function(app) {
- app.get('/users/:id', userService.getUserById);
- app.get('/users', userService.getAllUsers);
- app.post('/themes', themeService.addTheme);
- app.get('/themes/:id', themeService.getThemeById);
- app.put('/themes/:id', themeService.updateTheme);
- app.delete('/themes/:id', themeService.deleteTheme);
- app.get('/themes', themeService.getThemes);
- app.get('/resources/:code', languageResourceService.getLanguageResourceByCode);
- app.get('/config', applicationConfigService.getApplicationConfig);
- app.post('/keepalive', applicationConfigService.keepAlive);
- app.get('/categories', categoryService.getAllCategories);
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement