Showing
1 changed file
with
68 additions
and
23 deletions
... | @@ -6,7 +6,7 @@ const fs=require('fs'); | ... | @@ -6,7 +6,7 @@ const fs=require('fs'); |
6 | const router = express.Router() | 6 | const router = express.Router() |
7 | const fileStore = require('session-file-store')(session); | 7 | const fileStore = require('session-file-store')(session); |
8 | const app = express(); | 8 | const app = express(); |
9 | -var flash = require('connect-flash'); | 9 | +var flash = require('connect-flash'); |
10 | var NaverStrategy = require('passport-naver').Strategy; | 10 | var NaverStrategy = require('passport-naver').Strategy; |
11 | var KakaoStrategy = require('passport-kakao').Strategy; | 11 | var KakaoStrategy = require('passport-kakao').Strategy; |
12 | 12 | ||
... | @@ -38,7 +38,7 @@ passport.deserializeUser(function(id, done) { //읽기 | ... | @@ -38,7 +38,7 @@ passport.deserializeUser(function(id, done) { //읽기 |
38 | 38 | ||
39 | //첫 페이지 | 39 | //첫 페이지 |
40 | app.get('/',(req,res)=>{ | 40 | app.get('/',(req,res)=>{ |
41 | - let page = getFirstPage('Passport','This is Passport Example Page',authInfo(req)); | 41 | + let page = getFirstPage('Welcome!','Food Recipe',authInfo(req)); |
42 | res.send(page); | 42 | res.send(page); |
43 | }); | 43 | }); |
44 | 44 | ||
... | @@ -57,7 +57,7 @@ app.get('/main',(req,res)=>{ | ... | @@ -57,7 +57,7 @@ app.get('/main',(req,res)=>{ |
57 | //로그인 페이지 | 57 | //로그인 페이지 |
58 | app.get('/login',(req,res)=>{ | 58 | app.get('/login',(req,res)=>{ |
59 | let page = getLoginButton(`<a href="/">뒤로가기</a>`); | 59 | let page = getLoginButton(`<a href="/">뒤로가기</a>`); |
60 | - res.send(page); | 60 | + res.send(page); |
61 | }); | 61 | }); |
62 | 62 | ||
63 | 63 | ||
... | @@ -75,7 +75,7 @@ passport.use(new LocalStrategy({ | ... | @@ -75,7 +75,7 @@ passport.use(new LocalStrategy({ |
75 | console.log(user); | 75 | console.log(user); |
76 | 76 | ||
77 | //아이디가 다를때 | 77 | //아이디가 다를때 |
78 | - if (id !== user.email){ | 78 | + if (id !== user.email){ |
79 | //alert("존재하는 아이디가 없습니다.") | 79 | //alert("존재하는 아이디가 없습니다.") |
80 | return done(null, false, { message: '아이디가 다르다' });} | 80 | return done(null, false, { message: '아이디가 다르다' });} |
81 | //비밀번호가 다를때 | 81 | //비밀번호가 다를때 |
... | @@ -89,18 +89,18 @@ passport.use(new LocalStrategy({ | ... | @@ -89,18 +89,18 @@ passport.use(new LocalStrategy({ |
89 | 89 | ||
90 | //로그인 처리 (Passport) | 90 | //로그인 처리 (Passport) |
91 | app.post('/login', | 91 | app.post('/login', |
92 | -passport.authenticate('local', { | 92 | +passport.authenticate('local', { |
93 | //성공시, 메인페이지 이동 | 93 | //성공시, 메인페이지 이동 |
94 | //실패시 로그인 페이지 이동 | 94 | //실패시 로그인 페이지 이동 |
95 | successRedirect: '/', | 95 | successRedirect: '/', |
96 | failureRedirect: '/login', | 96 | failureRedirect: '/login', |
97 | badRequestMessage : 'Missing username or password.', | 97 | badRequestMessage : 'Missing username or password.', |
98 | - failureFlash: true | 98 | + failureFlash: true |
99 | })); | 99 | })); |
100 | 100 | ||
101 | //로그 아웃 처리 | 101 | //로그 아웃 처리 |
102 | app.get('/logout',(req,res)=>{ | 102 | app.get('/logout',(req,res)=>{ |
103 | - | 103 | + |
104 | //passport 정보 삭제 | 104 | //passport 정보 삭제 |
105 | req.logout(); | 105 | req.logout(); |
106 | //서버측 세션 삭제 | 106 | //서버측 세션 삭제 |
... | @@ -124,20 +124,20 @@ const authInfo = (req)=>{ | ... | @@ -124,20 +124,20 @@ const authInfo = (req)=>{ |
124 | // naver 로그인 | 124 | // naver 로그인 |
125 | app.get('/naverlogin', passport.authenticate('naver')); | 125 | app.get('/naverlogin', passport.authenticate('naver')); |
126 | passport.use('naver',new NaverStrategy({ | 126 | passport.use('naver',new NaverStrategy({ |
127 | - clientID: 'CGVVomc0bhMhzfzbytK2', | 127 | + clientID: 'CGVVomc0bhMhzfzbytK2', |
128 | - clientSecret: 'XHylcjnZxG', | 128 | + clientSecret: 'XHylcjnZxG', |
129 | callbackURL: "http://localhost:3000/", | 129 | callbackURL: "http://localhost:3000/", |
130 | svcType: 0, | 130 | svcType: 0, |
131 | authType: 'reauthenticate' // enable re-authentication | 131 | authType: 'reauthenticate' // enable re-authentication |
132 | - }, | 132 | + }, |
133 | - | 133 | + |
134 | - function(accessToken, refreshToken, profile, done) { | 134 | + function(accessToken, refreshToken, profile, done) { |
135 | var _profile = profile._json; | 135 | var _profile = profile._json; |
136 | console.log(_profile.id); | 136 | console.log(_profile.id); |
137 | console.log(_profile.properties.nickname); | 137 | console.log(_profile.properties.nickname); |
138 | - } | 138 | + } |
139 | )); | 139 | )); |
140 | - | 140 | + |
141 | 141 | ||
142 | // kakao 로그인 | 142 | // kakao 로그인 |
143 | app.get('/kakaologin', passport.authenticate('kakao-login')); | 143 | app.get('/kakaologin', passport.authenticate('kakao-login')); |
... | @@ -230,7 +230,7 @@ app.get('/join',(req,res)=>{ | ... | @@ -230,7 +230,7 @@ app.get('/join',(req,res)=>{ |
230 | </style><link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> | 230 | </style><link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> |
231 | <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> | 231 | <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> |
232 | <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> | 232 | <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> |
233 | - | 233 | + |
234 | </head> | 234 | </head> |
235 | 235 | ||
236 | <body> | 236 | <body> |
... | @@ -254,7 +254,7 @@ app.get('/join',(req,res)=>{ | ... | @@ -254,7 +254,7 @@ app.get('/join',(req,res)=>{ |
254 | </button> | 254 | </button> |
255 | </form> | 255 | </form> |
256 | </html> | 256 | </html> |
257 | - | 257 | + |
258 | `,'<a href="/login">뒤로가기</a>'); | 258 | `,'<a href="/login">뒤로가기</a>'); |
259 | res.send(page); | 259 | res.send(page); |
260 | }); | 260 | }); |
... | @@ -371,7 +371,7 @@ const getLoginButton = (auth) =>{ | ... | @@ -371,7 +371,7 @@ const getLoginButton = (auth) =>{ |
371 | <button type="submit" class="btn btn btn-primary"> | 371 | <button type="submit" class="btn btn btn-primary"> |
372 | <a href="/join" style="color:white;text-decoration-line:none;"> 회원가입</a> | 372 | <a href="/join" style="color:white;text-decoration-line:none;"> 회원가입</a> |
373 | </form> | 373 | </form> |
374 | - | 374 | + |
375 | </div> | 375 | </div> |
376 | </div> | 376 | </div> |
377 | </div> | 377 | </div> |
... | @@ -380,8 +380,8 @@ const getLoginButton = (auth) =>{ | ... | @@ -380,8 +380,8 @@ const getLoginButton = (auth) =>{ |
380 | <a href="/naverlogin" class="btn btn-block btn-lg btn-success btn_login">Naver</a> | 380 | <a href="/naverlogin" class="btn btn-block btn-lg btn-success btn_login">Naver</a> |
381 | <a href="/kakaologin" class="btn btn-block btn-lg btn-warning btn_login">KaKao</a> | 381 | <a href="/kakaologin" class="btn btn-block btn-lg btn-warning btn_login">KaKao</a> |
382 | </div> | 382 | </div> |
383 | - | 383 | + |
384 | - | 384 | + |
385 | </body> | 385 | </body> |
386 | </html> | 386 | </html> |
387 | `; | 387 | `; |
... | @@ -398,13 +398,59 @@ const getFirstPage =(title, content, auth) =>{ | ... | @@ -398,13 +398,59 @@ const getFirstPage =(title, content, auth) =>{ |
398 | <meta http-equiv="X-UA-Compatible" content="IE=edge"> | 398 | <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
399 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> | 399 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
400 | <title>Passport Example</title> | 400 | <title>Passport Example</title> |
401 | + <style> | ||
402 | + body{ | ||
403 | + height: 100vh; | ||
404 | + background-image: url('https://images.unsplash.com/photo-1614548539924-5c1f205b3747?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1170&q=80'); | ||
405 | + background-position: center; | ||
406 | + background-repeat: no-repeat; | ||
407 | + background-size: cover; | ||
408 | + background-attachment: scroll; | ||
409 | + } | ||
410 | + h1 { | ||
411 | + position: absolute; | ||
412 | + left: 50%; | ||
413 | + top: 30%; | ||
414 | + transform: translate(-50%, -30%); | ||
415 | + text-align: center; | ||
416 | + font-size: 5em; | ||
417 | + font-family: cursive;; | ||
418 | + } | ||
419 | + p { | ||
420 | + position: relative; | ||
421 | + left: 50%; | ||
422 | + top: 47%; | ||
423 | + transform: translate(-50%, -47%); | ||
424 | + font-size: 3em; | ||
425 | + text-align: center; | ||
426 | + } | ||
427 | + div { | ||
428 | + position: relative; | ||
429 | + font-size: 1.3em; | ||
430 | + text-align: center; | ||
431 | + } | ||
432 | + .box1{ | ||
433 | + position: relative; | ||
434 | + left: 50%; | ||
435 | + top: 50%; | ||
436 | + transform: translate(-50%, -50%); | ||
437 | + } | ||
438 | + .box2{ | ||
439 | + position: relative; | ||
440 | + left: 50%; | ||
441 | + top: 54%; | ||
442 | + transform: translate(-50%, -54%); | ||
443 | + } | ||
444 | + </style> | ||
401 | </head> | 445 | </head> |
402 | <body> | 446 | <body> |
403 | - ${auth} | ||
404 | <h1>${title}</h1> | 447 | <h1>${title}</h1> |
405 | <p>${content}</p> | 448 | <p>${content}</p> |
406 | - <div> | 449 | + <div class="box1"> |
407 | - <input type="button" value="page move" onClick="movepage()"/> | 450 | + ${auth} |
451 | + </div> | ||
452 | + <div class="box2"> | ||
453 | + <input type="button" value="레시피 보러가기" onClick="movepage()"/> | ||
408 | </div> | 454 | </div> |
409 | <script type="text/javascript"> | 455 | <script type="text/javascript"> |
410 | function movepage(){ | 456 | function movepage(){ |
... | @@ -415,4 +461,3 @@ const getFirstPage =(title, content, auth) =>{ | ... | @@ -415,4 +461,3 @@ const getFirstPage =(title, content, auth) =>{ |
415 | `; | 461 | `; |
416 | 462 | ||
417 | } | 463 | } |
418 | - | ... | ... |
-
Please register or login to post a comment