Skip to content

Commit 54e486d

Browse files
committed
헤더 작성
1 parent 3c6169e commit 54e486d

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed

app.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ app.use(passport.session());
7171
//플래시 메시지 관련
7272
app.use(flash());
7373

74+
//로그인 정보 뷰에서만 변수로 셋팅, 전체 미들웨어는 router위에 두어야 에러가 안난다
75+
app.use(function(req,res,next){
76+
app.locals.isLogin = req.isAuthenticated();
77+
//app.locals.lecture = "nodejs";//app.locals는 view에서 언제든지 사용가능하게
78+
//app.locals.urlparameter = req.url; //현재 url 정보를 보내고 싶으면 이와같이 셋팅
79+
//app.locals.userData = req.user; //사용 정보를 보내고 싶으면 이와같이 셋팅
80+
next();
81+
});
82+
7483

7584

7685

routes/accounts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ router.post('/login',
7272
}),
7373
function(req,res){
7474
res.send('<script>alert("로그인 성공");\
75-
location.href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3Cspan+class%3D"x x-first x-last">accounts/success";</script>');
75+
location.href="proxy.php?url=https%3A%2F%2Fgithub.com%2F";</script>');
7676
}
7777
);
7878

routes/auth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ router.get('/facebook',passport.authenticate('facebook',{scope:'email'}));
5151
router.get('/facebook/callback',
5252
passport.authenticate('facebook',
5353
{// 분기만 해줌
54-
successRedirect: '/auth/facebook/success',
54+
successRedirect: '/',
5555
failureRedirect: '/auth/facebook/fail'
5656
}
5757
)

views/header.ejs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,36 @@
1313
<!--폰트어섬추가 -->
1414
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
1515
<!--폰트어섬추가 -->
16+
<!--bootstrap js 추가 -->
17+
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
1618
</head>
1719
<body>
18-
<div class="container" style="padding-top:100px;">
20+
<div class="container" style="padding-top: 10px;">
21+
<nav class="navbar navbar-inverse">
22+
<div class="container-fluid">
23+
<div class="navbar-header">
24+
<!-- 오른쪽 메뉴바 -->
25+
<button type="button" class="collapsed navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-9" aria-expanded="false">
26+
<span class="sr-only">Toggle navigation</span>
27+
<span class="icon-bar"></span>
28+
<span class="icon-bar"></span>
29+
<span class="icon-bar"></span>
30+
</button>
31+
<a href="/" class="navbar-brand">Nodejs</a>
32+
</div>
33+
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-9">
34+
<ul class="nav navbar-nav">
35+
<li class="active">
36+
<a href="/">Home</a>
37+
</li>
38+
<li><a href="/admin/products">ADMIN</a></li>
39+
<% if(isLogin){%>
40+
<li><a href="/accounts/logout" onclick="return confirm('로그아웃 하시겠습니까?')">LOGOUT</a></li>
41+
<%}else{%>
42+
<li><a href="/accounts/join">JOIN</a></li>
43+
<li><a href="/accounts/login">LOGIN</a></li>
44+
<%}%>
45+
</ul>
46+
</div>
47+
</div>
48+
</nav>

0 commit comments

Comments
 (0)