router.js 750 Bytes
const express = require('express')
const router = express.Router()
const fs=require('fs')
const passport = require('./passport.js')
const path = require('path');
 
router.get('/', (req, res) => {
    res.render('index', {title: "인덱스"})
})
 
//로그인창
router.post('/', passport.authenticate('local-login', {
    successRedirect : '/loginSuccess', 
    failureRedirect : '/loginFail', 
    failureFlash : true 
}))
 
//로그인성공
router.get('/loginSuccess', (req, res) => {
    res.render('loginSuccess')
})

//로그인실패
router.get('/loginFail', (req, res) => {
    res.render('loginFail')
})

//메인화면
router.get('/main', (req, res)=>{
    res.sendFile(path.join(__dirname+'/main/main.html'));
  })

module.exports = router