Skip to content

Commit

Permalink
#20 로그인 정보 세션에 담아서 유저정보로 프로필 띄우기
Browse files Browse the repository at this point in the history
  • Loading branch information
AYoungSn committed Dec 15, 2021
1 parent b1548a3 commit ea0e19b
Show file tree
Hide file tree
Showing 528 changed files with 19,266 additions and 50 deletions.
22 changes: 20 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const port = 3000;
const bodyParser = require('body-parser');
const indexRouter = require('./routes/indexRouter.js')
const session = require('express-session');
const MySQLStore = require('express-mysql-session')(session);

const oauthRouter = require('./routes/loginRouter.js');

const boardRouter = require('./routes/boardRouter.js')
Expand All @@ -13,21 +15,30 @@ const flash = require('connect-flash');

const passportConfig = require('./passport');
const cookieParser = require('cookie-parser');

app.use(cookieParser('ras'));
passportConfig();
// parse application/x-www-form-urlencoded
// 사용자가 요청할 때 마다 호출
app.use(bodyParser.urlencoded({extended: false}));
app.use(session({
secret: 'ras',
resave: true,
resave: false,
secure: false,
saveUninitialized: true
saveUninitialized: true,
store: new MySQLStore({
host: "localhost",
port: 3306,
user: "root",
password: "qwerty123",
database: "hialcohol"
})
}));
app.use(passport.initialize());
app.use(passport.session());
app.use(flash());


// 정적 파일 (css, js) 경로 등록
// public 아래에 정적 파일 정리
app.use('/public', express.static( __dirname + '/public'));
Expand All @@ -38,6 +49,13 @@ app.use('/', indexRouter);
app.use('/board', boardRouter);
app.use('/search_list', search_listRouter);

app.get('/logout', function(req, res) {
req.logout();
req.session.save(() => {
res.redirect('/');
})
});

app.use(function(req, res, next) {
res.status(404).send('Sorry cant find that!');
});
Expand Down
41 changes: 41 additions & 0 deletions node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions node_modules/express-mysql-session/.github/FUNDING.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions node_modules/express-mysql-session/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions node_modules/express-mysql-session/changelog.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ea0e19b

Please sign in to comment.