Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // have to export everything that we create here so that it's available to the server file
- // have to use path because the path is relative to the current directory of routes.js
- var path = require('path');
- module.exports = function (app, passport) {
- // this is the 'home' page
- app.get('/', function (req, res) {
- res.sendFile(path.join(__dirname, '../client', '/views/index.html'));
- });
- // this would be the login page
- app.get('/login', function (req, res) {
- res.sendFile(path.join(__dirname, '../client', '/views/login.html'));
- });
- app.post('/login', passport.authenticate('local', {
- successRedirect: '/',
- failureRedirect: '/login'
- }));
- // this is the signup form
- app.get('/signup', function (req, res) {
- res.sendFile(path.join(__dirname, '../client', '/views/signup.html'));
- });
- // make a profile page
- app.get('/profile', function (req, res) {
- res.sendFile(path.join(__dirname, '../client', '/views/profile.html'));
- });
- app.get('/logout', function (req, res) {
- req.logout();
- res.redirect('/');
- });
- // define the is logged in function
- function isLoggedIn(req, res, next) {
- if (req.isAuthenticated()) return next();
- res.redirect('/');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement