hyunjong

카카오 로그인 연동 시도,......git add *git add *git add * 3시간넘게함

1 -<!doctype html>
2 -<html>
3 -<head>
4 - <title>WEB1 - HTML</title>
5 - <meta charset="utf-8">
6 -</head>
7 -<body>
8 - <h1><a href="index.html">WEB</a></h1>
9 - <ol>
10 - <li><a href="1.html">HTML</a></li>
11 - <li><a href="2.html">CSS</a></li>
12 - <li><a href="3.html">JavaScript</a></li>
13 - </ol>
14 - <h2>HTML</h2>
15 - <p><a href="https://www.w3.org/TR/html5/" target="_blank" title="html5 speicification">Hypertext Markup Language (HTML)</a> is the standard markup language for <strong>creating <u>web</u> pages</strong> and web applications.Web browsers receive HTML documents from a web server or from local storage and render them into multimedia web pages. HTML describes the structure of a web page semantically and originally included cues for the appearance of the document.
16 - <img src="coding.jpg" width="100%">
17 - </p><p style="margin-top:45px;">HTML elements are the building blocks of HTML pages. With HTML constructs, images and other objects, such as interactive forms, may be embedded into the rendered page. It provides a means to create structured documents by denoting structural semantics for text such as headings, paragraphs, lists, links, quotes and other items. HTML elements are delineated by tags, written using angle brackets.
18 - </p>
19 -</body>
20 -</html>
1 -<!doctype html>
2 -<html>
3 -<head>
4 - <title>WEB1 - CSS</title>
5 - <meta charset="utf-8">
6 -</head>
7 -<body>
8 - <h1><a href="index.html">WEB</a></h1>
9 - <ol>
10 - <li><a href="1.html">HTML</a></li>
11 - <li><a href="2.html">CSS</a></li>
12 - <li><a href="3.html">JavaScript</a></li>
13 - </ol>
14 - <h2>CSS</h2>
15 - <p>
16 - Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a document written in a markup language. Although most often used to set the visual style of web pages and user interfaces written in HTML and XHTML, the language can be applied to any XML document, including plain XML, SVG and XUL, and is applicable to rendering in speech, or on other media. Along with HTML and JavaScript, CSS is a cornerstone technology used by most websites to create visually engaging webpages, user interfaces for web applications, and user interfaces for many mobile applications.
17 - </p>
18 -</body>
19 -</html>
1 -<!doctype html>
2 -<html>
3 -<head>
4 - <title>WEB1 - JavaScript</title>
5 - <meta charset="utf-8">
6 -</head>
7 -<body>
8 - <h1><a href="index.html">WEB</a></h1>
9 - <ol>
10 - <li><a href="1.html">HTML</a></li>
11 - <li><a href="2.html">CSS</a></li>
12 - <li><a href="3.html">JavaScript</a></li>
13 - </ol>
14 - <h2>JavaScript</h2>
15 - <p>
16 - JavaScript (/ˈdʒɑːvəˌskrɪpt/[6]), often abbreviated as JS, is a high-level, dynamic, weakly typed, prototype-based, multi-paradigm, and interpreted programming language. Alongside HTML and CSS, JavaScript is one of the three core technologies of World Wide Web content production. It is used to make webpages interactive and provide online programs, including video games. The majority of websites employ it, and all modern web browsers support it without the need for plug-ins by means of a built-in JavaScript engine. Each of the many JavaScript engines represent a different implementation of JavaScript, all based on the ECMAScript specification, with some engines not supporting the spec fully, and with many engines supporting additional features beyond ECMA.
17 - </p>
18 -</body>
19 -</html>
1 -<input type="checkbox">
2 -<input type="checkbox">
3 -<input type="checkbox">
1 - Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a document written in a markup language. Although most often used to set the visual style of web pages and user interfaces written in HTML and XHTML, the language can be applied to any XML document, including plain XML, SVG and XUL, and is applicable to rendering in speech, or on other media. Along with HTML and JavaScript, CSS is a cornerstone technology used by most websites to create visually engaging webpages, user interfaces for web applications, and user interfaces for many mobile applications.
1 -<a href="https://www.w3.org/TR/html5/" target="_blank" title="html5 speicification">Hypertext Markup Language (HTML)</a> is the standard markup language for <strong>creating <u>web</u> pages</strong> and web applications.Web browsers receive HTML documents from a web server or from local storage and render them into multimedia web pages. HTML describes the structure of a web page semantically and originally included cues for the appearance of the document.
2 -<img src="coding.jpg" width="100%">
3 -</p><p style="margin-top:45px;">HTML elements are the building blocks of HTML pages. With HTML constructs, images and other objects, such as interactive forms, may be embedded into the rendered page. It provides a means to create structured documents by denoting structural semantics for text such as headings, paragraphs, lists, links, quotes and other items. HTML elements are delineated by tags, written using angle brackets.
1 - JavaScript (/ˈdʒɑːvəˌskrɪpt/[6]), often abbreviated as JS, is a high-level, dynamic, weakly typed, prototype-based, multi-paradigm, and interpreted programming language. Alongside HTML and CSS, JavaScript is one of the three core technologies of World Wide Web content production. It is used to make webpages interactive and provide online programs, including video games. The majority of websites employ it, and all modern web browsers support it without the need for plug-ins by means of a built-in JavaScript engine. Each of the many JavaScript engines represent a different implementation of JavaScript, all based on the ECMAScript specification, with some engines not supporting the spec fully, and with many engines supporting additional features beyond ECMA.
1 -<!doctype html>
2 -<html>
3 -<head>
4 - <title>WEB1 - Welcome</title>
5 - <meta charset="utf-8">
6 -</head>
7 -<body>
8 - <h1><a href="index.html">WEB</a></h1>
9 - <ol>
10 - <li><a href="1.html">HTML</a></li>
11 - <li><a href="2.html">CSS</a></li>
12 - <li><a href="3.html">JavaScript</a></li>
13 - </ol>
14 - <h2>WEB</h2>
15 - <p>The World Wide Web (abbreviated WWW or the Web) is an information space where documents and other web resources are identified by Uniform Resource Locators (URLs), interlinked by hypertext links, and can be accessed via the Internet.[1] English scientist Tim Berners-Lee invented the World Wide Web in 1989. He wrote the first web browser computer program in 1990 while employed at CERN in Switzerland.[2][3] The Web browser was released outside of CERN in 1991, first to other research institutions starting in January 1991 and to the general public on the Internet in August 1991.
16 - </p>
17 -</body>
18 -</html>
1 -var http = require('http');
2 -var fs = require('fs');
3 -var url = require('url');
4 -
5 -var app = http.createServer(function(request,response){
6 - var _url = request.url;
7 - var queryData = url.parse(_url, true).query;
8 - var pathname = url.parse(_url, true).pathname;
9 - var title = queryData.id;
10 -
11 - if(pathname === '/'){
12 - fs.readFile(`data/${queryData.id}`, 'utf8', function(err, description){
13 - var template = `
14 - <!doctype html>
15 - <html>
16 - <head>
17 - <title>WEB1 - ${title}</title>
18 - <meta charset="utf-8">
19 - </head>
20 - <body>
21 - <h1><a href="/">WEB</a></h1>
22 - <ul>
23 - <li><a href="/?id=HTML">HTML</a></li>
24 - <li><a href="/?id=CSS">CSS</a></li>
25 - <li><a href="/?id=JavaScript">JavaScript</a></li>
26 - </ul>
27 - <h2>${title}</h2>
28 - <p>${description}</p>
29 - </body>
30 - </html>`;
31 - response.writeHead(200);
32 - response.end(template);
33 - });
34 - } else {
35 - response.writeHead(404);
36 - response.end('Not found');
37 - }
38 -
39 -});
40 -app.listen(3000);
41 -
42 -// App - 홈페이지 구현
1 -var fs = require('fs');
2 -fs.readFile('sample.txt', 'utf8', function(err, data){
3 - console.log(data);
4 -});
1 -Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
1 -console.log(true);
2 -console.log(false);
1 -console.log(1==1); //true
2 -console.log(1==2); //false
3 -console.log(1>2); //false
4 -console.log(1<2); //false
5 -console.log(1===1); //true
6 -console.log(1===2); //false
1 -var args = process.argv;
2 -console.log(args[2]); // 1번째 런타임 위치, 2번째 파일위치, 3번째부터 input값
3 -console.log('A');
4 -console.log('B');
5 -if(args[2] === '1'){
6 - console.log('C1');
7 -} else {
8 - console.log('C2');
9 -}
10 -console.log('D');
1 -console.log('1'+'1');
2 -console.log('Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'.length);
1 -var name = 'k8805';
2 -
3 -var letter = 'Lorem' + name + 'dolor sit amet, \n\consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute ' + name + ' dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat ' + name + ' proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';
4 -
5 -var letter = `Lorem ${name}
6 -
7 -dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute ${name} dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat ${name} proident, sunt in culpa qui officia deserunt mollit anim id est laborum.`;
8 -
9 -console.log(letter);
10 -
11 -var a = 1;
12 -var b = '1';
1 -a = 1;
2 -console.log(a);
3 -a = 2;
4 -console.log(a);
1 -var letter = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';
2 -
3 -console.log(letter);
...@@ -49,14 +49,14 @@ var setting = require('./routes/setting'); ...@@ -49,14 +49,14 @@ var setting = require('./routes/setting');
49 49
50 // 최초 로그인 성공시 (Strategy 성공시) 단 한번만 호출 50 // 최초 로그인 성공시 (Strategy 성공시) 단 한번만 호출
51 passport.serializeUser(function(user, done) { 51 passport.serializeUser(function(user, done) {
52 - console.log('serialized'); 52 + console.log('serialized');
53 - done(null, user); 53 + done(null, user);
54 }); 54 });
55 55
56 // 페이지 리로드마다 (서버로 들어오는 requset) 로그인한 사용자인지 조회 56 // 페이지 리로드마다 (서버로 들어오는 requset) 로그인한 사용자인지 조회
57 passport.deserializeUser(function(user, done) { 57 passport.deserializeUser(function(user, done) {
58 - console.log('deserialized'); 58 + console.log('deserialized');
59 - done(null, user); 59 + done(null, user);
60 }); 60 });
61 61
62 var app = express(); 62 var app = express();
...@@ -69,7 +69,7 @@ app.set('view engine', 'ejs'); ...@@ -69,7 +69,7 @@ app.set('view engine', 'ejs');
69 // app.use(favicon(path.join(__dirname, 'public', 'favicon.ico'))); 69 // app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
70 app.use(logger('dev')); 70 app.use(logger('dev'));
71 app.use(bodyParser.json()); 71 app.use(bodyParser.json());
72 -app.use(bodyParser.urlencoded({ extended: false })); 72 +app.use(bodyParser.urlencoded({extended: false}));
73 app.use(cookieParser()); 73 app.use(cookieParser());
74 app.use(express.static(path.join(__dirname, 'public'))); 74 app.use(express.static(path.join(__dirname, 'public')));
75 75
...@@ -84,9 +84,9 @@ connection = mysql.createConnection({ ...@@ -84,9 +84,9 @@ connection = mysql.createConnection({
84 84
85 // 로그인 세션 85 // 로그인 세션
86 app.use(session({ 86 app.use(session({
87 - secret: 'secrettexthere', 87 + secret : 'secrettexthere',
88 - saveUninitialized: true, 88 + saveUninitialized : true,
89 - resave: true 89 + resave : true
90 })); 90 }));
91 91
92 //app.use(express.static('views')); 92 //app.use(express.static('views'));
......
1 +# Change Log
2 +
3 +## v0.9.0 / 2017-12-18
4 +### Fixed
5 +- incorrect result when first bit is 1 of bytes.
6 +
7 +### Changed
8 +- throw error by Error oject. #13
9 +
10 +### Added
11 +- TypeScript interfaces. #12
12 +
13 +## v0.8.0 / 2017-11-19
14 +### Added
15 +- support for web worker.
16 +- typescript types. #10
17 +
18 +### Changed
19 +- prevent webpack to require dependencies.
20 +
21 +## v0.7.1 / 2017-10-31
22 +### Improved
23 +- performance of hBytes increment.
24 +
25 +## v0.7.0 / 2017-10-31
26 +### Fixed
27 +- incorrect result when file size >= 512M.
28 +
29 +## v0.6.0 / 2017-07-11
30 +### Added
31 +- HMAC feature.
32 +
33 +### Changed
34 +- throw error if input type is incorrect.
35 +
36 +## v0.5.0 / 2017-01-24
37 +### Added
38 +- Streaming support #6
39 +
40 +## v0.4.0 / 2017-01-23
41 +### Added
42 +- AMD support.
43 +
44 +### Fixed
45 +- ArrayBuffer dosen't work in Webpack.
46 +
47 +## v0.3.2 / 2016-09-12
48 +### Added
49 +- CommonJS detection.
50 +
51 +## v0.3.1 / 2016-09-08
52 +### Added
53 +- some files to npm package.
54 +
55 +### Fixed
56 +- coding style.
57 +
58 +## v0.3.0 / 2015-05-23
59 +### Added
60 +- support for ArrayBuffer input.
61 +
62 +## v0.2.3 / 2015-02-11
63 +### Added
64 +- support for byte array input.
65 +
66 +## v0.2.2 / 2015-02-10
67 +### Improved
68 +- performance.
69 +
70 +## v0.2.1 / 2015-02-05
71 +### Fixed
72 +- special length bug.
73 +
74 +### Added
75 +- test cases.
76 +
77 +## v0.2.0 / 2015-02-03
78 +### Removed
79 +- ascii parameter.
80 +
81 +### Improved
82 +- performance.
83 +
84 +### Added
85 +- test cases.
86 +
87 +## v0.1.4 / 2015-01-24
88 +### Improved
89 +- performance.
90 +
91 +## v0.1.3 / 2015-01-09
92 +### Improved
93 +- performance.
94 +
95 +## v0.1.2 / 2015-01-06
96 +### Added
97 +- bower package.
98 +- travis.
99 +- coveralls.
100 +
101 +### Fixed
102 +- JSHint warnings.
103 +
104 +## v0.1.1 / 2014-07-27
105 +### Fixed
106 +- accents bug.
107 +
108 +## v0.1.0 / 2014-01-05
109 +### Added
110 +- initial release.
1 +Copyright (c) 2014-2017 Chen, Yi-Cyuan
2 +
3 +MIT License
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining
6 +a copy of this software and associated documentation files (the
7 +"Software"), to deal in the Software without restriction, including
8 +without limitation the rights to use, copy, modify, merge, publish,
9 +distribute, sublicense, and/or sell copies of the Software, and to
10 +permit persons to whom the Software is furnished to do so, subject to
11 +the following conditions:
12 +
13 +The above copyright notice and this permission notice shall be
14 +included in all copies or substantial portions of the Software.
15 +
16 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 +# js-sha256
2 +[![Build Status](https://travis-ci.org/emn178/js-sha256.svg?branch=master)](https://travis-ci.org/emn178/js-sha256)
3 +[![Coverage Status](https://coveralls.io/repos/emn178/js-sha256/badge.svg?branch=master)](https://coveralls.io/r/emn178/js-sha256?branch=master)
4 +[![CDNJS](https://img.shields.io/cdnjs/v/js-sha256.svg)](https://cdnjs.com/libraries/js-sha256/)
5 +[![NPM](https://nodei.co/npm/js-sha256.png?stars&downloads)](https://nodei.co/npm/js-sha256/)
6 +A simple SHA-256 / SHA-224 hash function for JavaScript supports UTF-8 encoding.
7 +
8 +## Demo
9 +[SHA256 Online](http://emn178.github.io/online-tools/sha256.html)
10 +[SHA224 Online](http://emn178.github.io/online-tools/sha224.html)
11 +
12 +## Download
13 +[Compress](https://raw.github.com/emn178/js-sha256/master/build/sha256.min.js)
14 +[Uncompress](https://raw.github.com/emn178/js-sha256/master/src/sha256.js)
15 +
16 +## Installation
17 +You can also install js-sha256 by using Bower.
18 +
19 + bower install js-sha256
20 +
21 +For node.js, you can use this command to install:
22 +
23 + npm install js-sha256
24 +
25 +## Usage
26 +You could use like this:
27 +```JavaScript
28 +sha256('Message to hash');
29 +sha224('Message to hash');
30 +
31 +var hash = sha256.create();
32 +hash.update('Message to hash');
33 +hash.hex();
34 +
35 +var hash2 = sha256.update('Message to hash');
36 +hash2.update('Message2 to hash');
37 +hash2.array();
38 +
39 +// HMAC
40 +sha256.hmac('key', 'Message to hash');
41 +sha224.hmac('key', 'Message to hash');
42 +
43 +var hash = sha256.hmac.create('key');
44 +hash.update('Message to hash');
45 +hash.hex();
46 +
47 +var hash2 = sha256.hmac.update('key', 'Message to hash');
48 +hash2.update('Message2 to hash');
49 +hash2.array();
50 +```
51 +If you use node.js, you should require the module first:
52 +```JavaScript
53 +var sha256 = require('js-sha256');
54 +```
55 +or
56 +```JavaScript
57 +var sha256 = require('js-sha256').sha256;
58 +var sha224 = require('js-sha256').sha224;
59 +```
60 +It supports AMD:
61 +```JavaScript
62 +require(['your/path/sha256.js'], function(sha256) {
63 +// ...
64 +});
65 +```
66 +or TypeScript
67 +```TypeScript
68 +import { sha256, sha224 } from 'js-sha256';
69 +```
70 +## Example
71 +```JavaScript
72 +sha256(''); // e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
73 +sha256('The quick brown fox jumps over the lazy dog'); // d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592
74 +sha256('The quick brown fox jumps over the lazy dog.'); // ef537f25c895bfa782526529a9b63d97aa631564d5d789c2b765448c8635fb6c
75 +sha224(''); // d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f
76 +sha224('The quick brown fox jumps over the lazy dog'); // 730e109bd7a8a32b1cb9d9a09aa2325d2430587ddbc0c38bad911525
77 +sha224('The quick brown fox jumps over the lazy dog.'); // 619cba8e8e05826e9b8c519c0a5c68f4fb653e8a3d8aa04bb2c8cd4c
78 +
79 +// It also supports UTF-8 encoding
80 +sha256('中文'); // 72726d8818f693066ceb69afa364218b692e62ea92b385782363780f47529c21
81 +sha224('中文'); // dfbab71afdf54388af4d55f8bd3de8c9b15e0eb916bf9125f4a959d4
82 +
83 +// It also supports byte `Array`, `Uint8Array`, `ArrayBuffer` input
84 +sha256([]); // e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
85 +sha256(new Uint8Array([211, 212])); // 182889f925ae4e5cc37118ded6ed87f7bdc7cab5ec5e78faef2e50048999473f
86 +
87 +// Different output
88 +sha256(''); // e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
89 +sha256.hex(''); // e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
90 +sha256.array(''); // [227, 176, 196, 66, 152, 252, 28, 20, 154, 251, 244, 200, 153, 111, 185, 36, 39, 174, 65, 228, 100, 155, 147, 76, 164, 149, 153, 27, 120, 82, 184, 85]
91 +sha256.digest(''); // [227, 176, 196, 66, 152, 252, 28, 20, 154, 251, 244, 200, 153, 111, 185, 36, 39, 174, 65, 228, 100, 155, 147, 76, 164, 149, 153, 27, 120, 82, 184, 85]
92 +sha256.arrayBuffer(''); // ArrayBuffer
93 +```
94 +
95 +## License
96 +The project is released under the [MIT license](http://www.opensource.org/licenses/MIT).
97 +
98 +## Contact
99 +The project's website is located at https://github.com/emn178/js-sha256
100 +Author: Chen, Yi-Cyuan (emn178@gmail.com)
1 +/**
2 + * [js-sha256]{@link https://github.com/emn178/js-sha256}
3 + *
4 + * @version 0.9.0
5 + * @author Chen, Yi-Cyuan [emn178@gmail.com]
6 + * @copyright Chen, Yi-Cyuan 2014-2017
7 + * @license MIT
8 + */
9 +!function(){"use strict";function t(t,i){i?(d[0]=d[16]=d[1]=d[2]=d[3]=d[4]=d[5]=d[6]=d[7]=d[8]=d[9]=d[10]=d[11]=d[12]=d[13]=d[14]=d[15]=0,this.blocks=d):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=t}function i(i,r,s){var e,n=typeof i;if("string"===n){var o,a=[],u=i.length,c=0;for(e=0;e<u;++e)(o=i.charCodeAt(e))<128?a[c++]=o:o<2048?(a[c++]=192|o>>6,a[c++]=128|63&o):o<55296||o>=57344?(a[c++]=224|o>>12,a[c++]=128|o>>6&63,a[c++]=128|63&o):(o=65536+((1023&o)<<10|1023&i.charCodeAt(++e)),a[c++]=240|o>>18,a[c++]=128|o>>12&63,a[c++]=128|o>>6&63,a[c++]=128|63&o);i=a}else{if("object"!==n)throw new Error(h);if(null===i)throw new Error(h);if(f&&i.constructor===ArrayBuffer)i=new Uint8Array(i);else if(!(Array.isArray(i)||f&&ArrayBuffer.isView(i)))throw new Error(h)}i.length>64&&(i=new t(r,!0).update(i).array());var y=[],p=[];for(e=0;e<64;++e){var l=i[e]||0;y[e]=92^l,p[e]=54^l}t.call(this,r,s),this.update(p),this.oKeyPad=y,this.inner=!0,this.sharedMemory=s}var h="input is invalid type",r="object"==typeof window,s=r?window:{};s.JS_SHA256_NO_WINDOW&&(r=!1);var e=!r&&"object"==typeof self,n=!s.JS_SHA256_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;n?s=global:e&&(s=self);var o=!s.JS_SHA256_NO_COMMON_JS&&"object"==typeof module&&module.exports,a="function"==typeof define&&define.amd,f=!s.JS_SHA256_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,u="0123456789abcdef".split(""),c=[-2147483648,8388608,32768,128],y=[24,16,8,0],p=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],l=["hex","array","digest","arrayBuffer"],d=[];!s.JS_SHA256_NO_NODE_JS&&Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),!f||!s.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer});var A=function(i,h){return function(r){return new t(h,!0).update(r)[i]()}},w=function(i){var h=A("hex",i);n&&(h=b(h,i)),h.create=function(){return new t(i)},h.update=function(t){return h.create().update(t)};for(var r=0;r<l.length;++r){var s=l[r];h[s]=A(s,i)}return h},b=function(t,i){var r=eval("require('crypto')"),s=eval("require('buffer').Buffer"),e=i?"sha224":"sha256",n=function(i){if("string"==typeof i)return r.createHash(e).update(i,"utf8").digest("hex");if(null===i||void 0===i)throw new Error(h);return i.constructor===ArrayBuffer&&(i=new Uint8Array(i)),Array.isArray(i)||ArrayBuffer.isView(i)||i.constructor===s?r.createHash(e).update(new s(i)).digest("hex"):t(i)};return n},v=function(t,h){return function(r,s){return new i(r,h,!0).update(s)[t]()}},_=function(t){var h=v("hex",t);h.create=function(h){return new i(h,t)},h.update=function(t,i){return h.create(t).update(i)};for(var r=0;r<l.length;++r){var s=l[r];h[s]=v(s,t)}return h};t.prototype.update=function(t){if(!this.finalized){var i,r=typeof t;if("string"!==r){if("object"!==r)throw new Error(h);if(null===t)throw new Error(h);if(f&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||f&&ArrayBuffer.isView(t)))throw new Error(h);i=!0}for(var s,e,n=0,o=t.length,a=this.blocks;n<o;){if(this.hashed&&(this.hashed=!1,a[0]=this.block,a[16]=a[1]=a[2]=a[3]=a[4]=a[5]=a[6]=a[7]=a[8]=a[9]=a[10]=a[11]=a[12]=a[13]=a[14]=a[15]=0),i)for(e=this.start;n<o&&e<64;++n)a[e>>2]|=t[n]<<y[3&e++];else for(e=this.start;n<o&&e<64;++n)(s=t.charCodeAt(n))<128?a[e>>2]|=s<<y[3&e++]:s<2048?(a[e>>2]|=(192|s>>6)<<y[3&e++],a[e>>2]|=(128|63&s)<<y[3&e++]):s<55296||s>=57344?(a[e>>2]|=(224|s>>12)<<y[3&e++],a[e>>2]|=(128|s>>6&63)<<y[3&e++],a[e>>2]|=(128|63&s)<<y[3&e++]):(s=65536+((1023&s)<<10|1023&t.charCodeAt(++n)),a[e>>2]|=(240|s>>18)<<y[3&e++],a[e>>2]|=(128|s>>12&63)<<y[3&e++],a[e>>2]|=(128|s>>6&63)<<y[3&e++],a[e>>2]|=(128|63&s)<<y[3&e++]);this.lastByteIndex=e,this.bytes+=e-this.start,e>=64?(this.block=a[16],this.start=e-64,this.hash(),this.hashed=!0):this.start=e}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},t.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,i=this.lastByteIndex;t[16]=this.block,t[i>>2]|=c[3&i],this.block=t[16],i>=56&&(this.hashed||this.hash(),t[0]=this.block,t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash()}},t.prototype.hash=function(){var t,i,h,r,s,e,n,o,a,f=this.h0,u=this.h1,c=this.h2,y=this.h3,l=this.h4,d=this.h5,A=this.h6,w=this.h7,b=this.blocks;for(t=16;t<64;++t)i=((s=b[t-15])>>>7|s<<25)^(s>>>18|s<<14)^s>>>3,h=((s=b[t-2])>>>17|s<<15)^(s>>>19|s<<13)^s>>>10,b[t]=b[t-16]+i+b[t-7]+h<<0;for(a=u&c,t=0;t<64;t+=4)this.first?(this.is224?(e=300032,w=(s=b[0]-1413257819)-150054599<<0,y=s+24177077<<0):(e=704751109,w=(s=b[0]-210244248)-1521486534<<0,y=s+143694565<<0),this.first=!1):(i=(f>>>2|f<<30)^(f>>>13|f<<19)^(f>>>22|f<<10),r=(e=f&u)^f&c^a,w=y+(s=w+(h=(l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7))+(l&d^~l&A)+p[t]+b[t])<<0,y=s+(i+r)<<0),i=(y>>>2|y<<30)^(y>>>13|y<<19)^(y>>>22|y<<10),r=(n=y&f)^y&u^e,A=c+(s=A+(h=(w>>>6|w<<26)^(w>>>11|w<<21)^(w>>>25|w<<7))+(w&l^~w&d)+p[t+1]+b[t+1])<<0,i=((c=s+(i+r)<<0)>>>2|c<<30)^(c>>>13|c<<19)^(c>>>22|c<<10),r=(o=c&y)^c&f^n,d=u+(s=d+(h=(A>>>6|A<<26)^(A>>>11|A<<21)^(A>>>25|A<<7))+(A&w^~A&l)+p[t+2]+b[t+2])<<0,i=((u=s+(i+r)<<0)>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),r=(a=u&c)^u&y^o,l=f+(s=l+(h=(d>>>6|d<<26)^(d>>>11|d<<21)^(d>>>25|d<<7))+(d&A^~d&w)+p[t+3]+b[t+3])<<0,f=s+(i+r)<<0;this.h0=this.h0+f<<0,this.h1=this.h1+u<<0,this.h2=this.h2+c<<0,this.h3=this.h3+y<<0,this.h4=this.h4+l<<0,this.h5=this.h5+d<<0,this.h6=this.h6+A<<0,this.h7=this.h7+w<<0},t.prototype.hex=function(){this.finalize();var t=this.h0,i=this.h1,h=this.h2,r=this.h3,s=this.h4,e=this.h5,n=this.h6,o=this.h7,a=u[t>>28&15]+u[t>>24&15]+u[t>>20&15]+u[t>>16&15]+u[t>>12&15]+u[t>>8&15]+u[t>>4&15]+u[15&t]+u[i>>28&15]+u[i>>24&15]+u[i>>20&15]+u[i>>16&15]+u[i>>12&15]+u[i>>8&15]+u[i>>4&15]+u[15&i]+u[h>>28&15]+u[h>>24&15]+u[h>>20&15]+u[h>>16&15]+u[h>>12&15]+u[h>>8&15]+u[h>>4&15]+u[15&h]+u[r>>28&15]+u[r>>24&15]+u[r>>20&15]+u[r>>16&15]+u[r>>12&15]+u[r>>8&15]+u[r>>4&15]+u[15&r]+u[s>>28&15]+u[s>>24&15]+u[s>>20&15]+u[s>>16&15]+u[s>>12&15]+u[s>>8&15]+u[s>>4&15]+u[15&s]+u[e>>28&15]+u[e>>24&15]+u[e>>20&15]+u[e>>16&15]+u[e>>12&15]+u[e>>8&15]+u[e>>4&15]+u[15&e]+u[n>>28&15]+u[n>>24&15]+u[n>>20&15]+u[n>>16&15]+u[n>>12&15]+u[n>>8&15]+u[n>>4&15]+u[15&n];return this.is224||(a+=u[o>>28&15]+u[o>>24&15]+u[o>>20&15]+u[o>>16&15]+u[o>>12&15]+u[o>>8&15]+u[o>>4&15]+u[15&o]),a},t.prototype.toString=t.prototype.hex,t.prototype.digest=function(){this.finalize();var t=this.h0,i=this.h1,h=this.h2,r=this.h3,s=this.h4,e=this.h5,n=this.h6,o=this.h7,a=[t>>24&255,t>>16&255,t>>8&255,255&t,i>>24&255,i>>16&255,i>>8&255,255&i,h>>24&255,h>>16&255,h>>8&255,255&h,r>>24&255,r>>16&255,r>>8&255,255&r,s>>24&255,s>>16&255,s>>8&255,255&s,e>>24&255,e>>16&255,e>>8&255,255&e,n>>24&255,n>>16&255,n>>8&255,255&n];return this.is224||a.push(o>>24&255,o>>16&255,o>>8&255,255&o),a},t.prototype.array=t.prototype.digest,t.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(this.is224?28:32),i=new DataView(t);return i.setUint32(0,this.h0),i.setUint32(4,this.h1),i.setUint32(8,this.h2),i.setUint32(12,this.h3),i.setUint32(16,this.h4),i.setUint32(20,this.h5),i.setUint32(24,this.h6),this.is224||i.setUint32(28,this.h7),t},i.prototype=new t,i.prototype.finalize=function(){if(t.prototype.finalize.call(this),this.inner){this.inner=!1;var i=this.array();t.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(i),t.prototype.finalize.call(this)}};var B=w();B.sha256=B,B.sha224=w(!0),B.sha256.hmac=_(),B.sha224.hmac=_(!0),o?module.exports=B:(s.sha256=B.sha256,s.sha224=B.sha224,a&&define(function(){return B}))}();
...\ No newline at end of file ...\ No newline at end of file
1 +type Message = string | number[] | ArrayBuffer | Uint8Array;
2 +
3 +interface Hasher {
4 + /**
5 + * Update hash
6 + *
7 + * @param message The message you want to hash.
8 + */
9 + update(message: Message): Hasher;
10 +
11 + /**
12 + * Return hash in hex string.
13 + */
14 + hex(): string;
15 +
16 + /**
17 + * Return hash in hex string.
18 + */
19 + toString(): string;
20 +
21 + /**
22 + * Return hash in ArrayBuffer.
23 + */
24 + arrayBuffer(): ArrayBuffer;
25 +
26 + /**
27 + * Return hash in integer array.
28 + */
29 + digest(): number[];
30 +
31 + /**
32 + * Return hash in integer array.
33 + */
34 + array(): number[];
35 +}
36 +
37 +interface Hmac {
38 + /**
39 + * Computes a Hash-based message authentication code (HMAC) using a secret key
40 + *
41 + * @param secretKey The Secret Key
42 + * @param message The message you want to hash.
43 + */
44 + (secretKey: string, message: Message): string;
45 +
46 + /**
47 + * Create a hash object using a secret key.
48 + *
49 + * @param secretKey The Secret Key
50 + */
51 + create(secretKey: string): Hasher;
52 +
53 + /**
54 + * Create a hash object and hash message using a secret key
55 + *
56 + * @param secretKey The Secret Key
57 + * @param message The message you want to hash.
58 + */
59 + update(secretKey: string, message: Message): Hasher;
60 +
61 + /**
62 + * Return hash in hex string.
63 + *
64 + * @param secretKey The Secret Key
65 + * @param message The message you want to hash.
66 + */
67 + hex(secretKey: string, message: Message): string;
68 +
69 + /**
70 + * Return hash in ArrayBuffer.
71 + *
72 + * @param secretKey The Secret Key
73 + * @param message The message you want to hash.
74 + */
75 + arrayBuffer(secretKey: string, message: Message): ArrayBuffer;
76 +
77 + /**
78 + * Return hash in integer array.
79 + *
80 + * @param secretKey The Secret Key
81 + * @param message The message you want to hash.
82 + */
83 + digest(secretKey: string, message: Message): number[];
84 +
85 + /**
86 + * Return hash in integer array.
87 + *
88 + * @param secretKey The Secret Key
89 + * @param message The message you want to hash.
90 + */
91 + array(secretKey: string, message: Message): number[];
92 +}
93 +
94 +interface Hash {
95 + /**
96 + * Hash and return hex string.
97 + *
98 + * @param message The message you want to hash.
99 + */
100 + (message: Message): string;
101 +
102 + /**
103 + * Create a hash object.
104 + */
105 + create(): Hasher;
106 +
107 + /**
108 + * Create a hash object and hash message.
109 + *
110 + * @param message The message you want to hash.
111 + */
112 + update(message: Message): Hasher;
113 +
114 + /**
115 + * Return hash in hex string.
116 + *
117 + * @param message The message you want to hash.
118 + */
119 + hex(message: Message): string;
120 +
121 + /**
122 + * Return hash in ArrayBuffer.
123 + *
124 + * @param message The message you want to hash.
125 + */
126 + arrayBuffer(message: Message): ArrayBuffer;
127 +
128 + /**
129 + * Return hash in integer array.
130 + *
131 + * @param message The message you want to hash.
132 + */
133 + digest(message: Message): number[];
134 +
135 + /**
136 + * Return hash in integer array.
137 + *
138 + * @param message The message you want to hash.
139 + */
140 + array(message: Message): number[];
141 +
142 + /**
143 + * HMAC interface
144 + */
145 + hmac: Hmac;
146 +}
147 +
148 +export var sha256: Hash;
149 +export var sha224: Hash;
1 +{
2 + "_from": "js-sha256",
3 + "_id": "js-sha256@0.9.0",
4 + "_inBundle": false,
5 + "_integrity": "sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA==",
6 + "_location": "/js-sha256",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "tag",
10 + "registry": true,
11 + "raw": "js-sha256",
12 + "name": "js-sha256",
13 + "escapedName": "js-sha256",
14 + "rawSpec": "",
15 + "saveSpec": null,
16 + "fetchSpec": "latest"
17 + },
18 + "_requiredBy": [
19 + "#USER",
20 + "/"
21 + ],
22 + "_resolved": "https://registry.npmjs.org/js-sha256/-/js-sha256-0.9.0.tgz",
23 + "_shasum": "0b89ac166583e91ef9123644bd3c5334ce9d0966",
24 + "_spec": "js-sha256",
25 + "_where": "C:\\Users\\LEEHYUNJONG\\Desktop\\오픈소스SW\\YTMT",
26 + "author": {
27 + "name": "Chen, Yi-Cyuan",
28 + "email": "emn178@gmail.com"
29 + },
30 + "bugs": {
31 + "url": "https://github.com/emn178/js-sha256/issues"
32 + },
33 + "bundleDependencies": false,
34 + "deprecated": false,
35 + "description": "A simple SHA-256 / SHA-224 hash function for JavaScript supports UTF-8 encoding.",
36 + "devDependencies": {
37 + "expect.js": "~0.3.1",
38 + "mocha": "~2.3.4",
39 + "nyc": "^11.3.0",
40 + "uglify-js": "^3.1.9",
41 + "webworker-threads": "^0.7.13"
42 + },
43 + "homepage": "https://github.com/emn178/js-sha256",
44 + "keywords": [
45 + "sha",
46 + "sha2",
47 + "sha224",
48 + "sha256",
49 + "hash",
50 + "encryption",
51 + "cryptography",
52 + "HMAC"
53 + ],
54 + "license": "MIT",
55 + "main": "src/sha256.js",
56 + "name": "js-sha256",
57 + "nyc": {
58 + "exclude": [
59 + "tests"
60 + ]
61 + },
62 + "repository": {
63 + "type": "git",
64 + "url": "git+https://github.com/emn178/js-sha256.git"
65 + },
66 + "scripts": {
67 + "build": "uglifyjs src/sha256.js -c -m eval --comments -o build/sha256.min.js",
68 + "coveralls": "nyc report --reporter=text-lcov | coveralls",
69 + "report": "nyc --reporter=html --reporter=text mocha tests/node-test.js",
70 + "test": "nyc mocha tests/node-test.js"
71 + },
72 + "version": "0.9.0"
73 +}
This diff is collapsed. Click to expand it.
...@@ -16,12 +16,13 @@ ...@@ -16,12 +16,13 @@
16 "fetchSpec": "0.0.5" 16 "fetchSpec": "0.0.5"
17 }, 17 },
18 "_requiredBy": [ 18 "_requiredBy": [
19 + "#USER",
19 "/" 20 "/"
20 ], 21 ],
21 "_resolved": "https://registry.npmjs.org/passport-kakao/-/passport-kakao-0.0.5.tgz", 22 "_resolved": "https://registry.npmjs.org/passport-kakao/-/passport-kakao-0.0.5.tgz",
22 "_shasum": "dcaab68800793af95566a15e7fef2dcabd3adc2d", 23 "_shasum": "dcaab68800793af95566a15e7fef2dcabd3adc2d",
23 "_spec": "passport-kakao@0.0.5", 24 "_spec": "passport-kakao@0.0.5",
24 - "_where": "D:\\OSS project\\YTMT", 25 + "_where": "C:\\Users\\LEEHYUNJONG\\Desktop\\오픈소스SW\\YTMT",
25 "author": { 26 "author": {
26 "name": "rotoshine@gmail.com" 27 "name": "rotoshine@gmail.com"
27 }, 28 },
......
...@@ -992,6 +992,11 @@ ...@@ -992,6 +992,11 @@
992 "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", 992 "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
993 "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" 993 "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo="
994 }, 994 },
995 + "js-sha256": {
996 + "version": "0.9.0",
997 + "resolved": "https://registry.npmjs.org/js-sha256/-/js-sha256-0.9.0.tgz",
998 + "integrity": "sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA=="
999 + },
995 "jsbn": { 1000 "jsbn": {
996 "version": "0.1.1", 1001 "version": "0.1.1",
997 "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", 1002 "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
17 "ejs": "^2.5.9", 17 "ejs": "^2.5.9",
18 "express": "^4.15.5", 18 "express": "^4.15.5",
19 "express-session": "^1.15.6", 19 "express-session": "^1.15.6",
20 + "js-sha256": "^0.9.0",
20 "mongoose": "^4.13.6", 21 "mongoose": "^4.13.6",
21 "morgan": "^1.9.0", 22 "morgan": "^1.9.0",
22 "mysql": "^2.16.0", 23 "mysql": "^2.16.0",
......
...@@ -2,65 +2,86 @@ var express = require('express'); ...@@ -2,65 +2,86 @@ var express = require('express');
2 var cheerio = require('cheerio'); 2 var cheerio = require('cheerio');
3 var request = require('request'); 3 var request = require('request');
4 var mysql = require('mysql'); 4 var mysql = require('mysql');
5 +var sha256 = require('js-sha256');
5 6
6 // 설명 7 // 설명
7 var client = require('cheerio-httpcli'); 8 var client = require('cheerio-httpcli');
8 -var passport = require('passport'), KakaoStrategy = require('passport-kakao').Strategy; 9 +var passport = require('passport')
10 +var KakaoStrategy = require('passport-kakao').Strategy;
9 var router = express.Router(); 11 var router = express.Router();
10 12
11 // 설명 13 // 설명
12 -passport.use(new KakaoStrategy({ 14 +var kakaoKey = {
13 - 15 + clientID : 'd7ba37067bddfb0661513607bb5eddef',
14 - clientID : 'bd2e610396fb7bbb84cf91a786b3cc72', 16 + clientSecret : 'NZQsjsqhzDnjjMqFuEY805wBM1AwIsBY',
15 - callbackURL :'/auth/login/kakao/callback', 17 + callbackURL : 'http://localhost:3000/api/auth/kakao/callback'
16 - clientSecret : 'eUtJGtlLoCZJufevp3LKfDP0KOtZUV7R' 18 +};
17 -
18 - }, function(accessToken, refreshToken,params, profile, done){
19 -
20 - //사용자 정보 -> profile
21 - loginByThirdparty(accessToken, refreshToken, profile);
22 - console.log("(!)로그인 : " + profile._json.id+"("+profile._json.properties.nickname +")");
23 -
24 - //return done(null,profile)
25 - return done(null, {
26 - 'user_id': profile._json.id,
27 - 'nickname': profile._json.properties.nickname
28 -
29 - });
30 - }
31 -));
32 19
33 -// kakao 로그인, // passport.authenticate('kakao',{state: "myStateValue"}) 20 +passport.use("kakao-login", new KakaoStrategy(kakaoKey, function(accessToken, refreshToken, profile, done){
34 -router.get('/auth/login/kakao', passport.authenticate('kakao')); 21 + var _profile = profile._json;
22 + console.log("error1");
23 + //사용자 정보는 profile에
24 + loginByThirdparty({
25 + 'auth_type': 'kakao',
26 + 'auth_id': _profile.id,
27 + 'auth_name': _profile.properties.nickname,
28 + 'auth_email': _profile.id
29 + }, done);
30 + console.log("(!)로그인 : " + profile._json.id + "(" + profile._json.properties.nickname + ")" );
31 + console.log("error2");
32 +}));
33 +
34 +// kakao 로그인, // passport.authenticate('kakao',{state: "myStateValue"})
35 +router.get('/api/auth/kakao', passport.authenticate('kakao-login'));
35 36
36 // kakao 로그인 연동 콜백 37 // kakao 로그인 연동 콜백
37 -router.get('/auth/login/kakao/callback', passport.authenticate('kakao', { 38 +router.get('/api/auth/kakao/callback', passport.authenticate('kakao-login', {
38 - 39 + //session: false,
39 - //session: false, 40 + successRedirect: '/routes/mytoons',
40 - successRedirect: '/mytoons', 41 + failureRedirect: '/'
41 - failureRedirect: '/' 42 + })
42 - })
43 ); 43 );
44 44
45 // 설명 45 // 설명
46 -function loginByThirdparty(accessToken, refreshToken, profile) { 46 +function loginByThirdparty(info, done) {
47 - // 예전 코드는 MySQL 버젼이 맞지 않음 47 + console.log("error3");
48 - // var sql = 'INSERT INTO `user`(id) VALUES(?) ON DUPLICATE KEY(PRIMARY) UPDATE id=(?);' 48 + // 예전 코드는 MySQL 버젼이 맞지 않음
49 - var sql = "INSERT INTO `user` (id) VALUES (?) ON DUPLICATE KEY UPDATE id=id"; 49 + // var sql = 'INSERT INTO `user`(id) VALUES(?) ON DUPLICATE KEY(PRIMARY) UPDATE id=(?);'
50 - var kid=[profile._json.id]; 50 + var sql = 'select *from `user` where `user_id` = ?';
51 - connection.query(sql,kid,function(err,result){ 51 +
52 - if (err) { 52 + connection.query(sql, info.auth_id, function(err,result){
53 - console.log("로그인 쿼리중 에러 : " + err); 53 + if (err) {
54 - } else { 54 + return done(err);
55 - console.log("로그인 DB처리 완료!"); 55 + } else {
56 - } 56 + if (result.length === 0) {
57 - }); 57 + // 신규 유저는 회원 가입 이후 로그인 처리
58 + var stmt_thridparty_signup = 'insert into `user` set `user_id`= ?, `nickname`= ?';
59 + connection.query(stmt_thridparty_signup, [info.auth_id, info.auth_name], function (err, result) {
60 + if(err){
61 + return done(err);
62 + }else{
63 + done(null, {
64 + 'user_id': info.auth_id,
65 + 'nickname': info.auth_name
66 + });
67 + }
68 + });
69 + } else {
70 + //기존유저 로그인 처리
71 + console.log('Old User');
72 + done(null, {
73 + 'user_id': result[0].user_id,
74 + 'nickname': result[0].nickname
75 + });
76 + }
77 + }
78 + });
58 } 79 }
59 80
60 // 설명 81 // 설명
61 -router.get('/auth/logout/kakao',function (req,res) { 82 +router.get('/api/auth/logout/kakao',function (req,res) {
62 - req.logout(); 83 + req.logout();
63 - res.redirect('/'); 84 + res.redirect('/');
64 }) 85 })
65 86
66 // 87 //
...@@ -74,35 +95,35 @@ allWebtoons = new Array(); ...@@ -74,35 +95,35 @@ allWebtoons = new Array();
74 // 설명 95 // 설명
75 function getAllToons() { 96 function getAllToons() {
76 97
77 - allWebtoonList = new Array(); 98 + allWebtoonList = new Array();
78 99
79 - //월요일 다음 웹툰 100 + //월요일 다음 웹툰
80 - var mon='mon'; 101 + var mon='mon';
81 - var mon_name='MON'; 102 + var mon_name='MON';
82 - var daum = `http://webtoon.daum.net/data/pc/webtoon/list_serialized/${mon}?timeStamp=1515819276574`; 103 + var daum = `http://webtoon.daum.net/data/pc/webtoon/list_serialized/${mon}?timeStamp=1515819276574`;
83 - var site = 'daum'; 104 + var site = 'daum';
84 105
85 - client.fetch(daum, {}, function (err, $, res, body) { 106 + client.fetch(daum, {}, function (err, $, res, body) {
86 107
87 - var data = JSON.parse(body); 108 + var data = JSON.parse(body);
88 - var list = data["data"]; 109 + var list = data["data"];
89 110
90 - list.forEach(function (item, idx) { 111 + list.forEach(function (item, idx) {
91 112
92 - var webtoon_link = 'http://webtoon.daum.net/webtoon/view/' + item.nickname.toString(); 113 + var webtoon_link = 'http://webtoon.daum.net/webtoon/view/' + item.nickname.toString();
93 - var webtoon = { 114 + var webtoon = {
94 - toon_index: item.id, 115 + toon_index: item.id,
95 - name: item.title, 116 + name: item.title,
96 - thum_link: item.pcThumbnailImage.url, 117 + thum_link: item.pcThumbnailImage.url,
97 - webtoon_link: webtoon_link, 118 + webtoon_link: webtoon_link,
98 - week :mon_name, 119 + week :mon_name,
99 - site: site, 120 + site: site,
100 - latest: 0 121 + latest: 0
101 - }; 122 + };
102 123
103 - allWebtoonList.push(webtoon); 124 + allWebtoonList.push(webtoon);
104 - });
105 }); 125 });
126 + });
106 127
107 //화요일 다음 웹툰 128 //화요일 다음 웹툰
108 var tue='tue'; 129 var tue='tue';
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
47 <ul class="nav navbar-nav navbar-right"> 47 <ul class="nav navbar-nav navbar-right">
48 <li><a href="#about" class="page-scroll">About</a></li> 48 <li><a href="#about" class="page-scroll">About</a></li>
49 <li><a href="#portfolio" class="page-scroll">Webtoons</a></li> 49 <li><a href="#portfolio" class="page-scroll">Webtoons</a></li>
50 - <li><a href="/auth/login/kakao" class="page-scroll">Login</a></li> 50 + <li><a href="/api/auth/kakao" class="page-scroll">로그인2</a></li>
51 </ul> 51 </ul>
52 </div> 52 </div>
53 <!-- /.navbar-collapse --> 53 <!-- /.navbar-collapse -->
......
1 +<div class="login">
2 + <h3>LOG IN</h3>
3 + <% if(!isLogin){%>
4 + <form action="/" id = "login_form" method = "post">
5 + <fieldset>
6 + <input placeholder = "ID" name = "username" type = "text", autofocus = "" require = "">
7 + <input placeholder = "password" name = "password" type = "password" value = "" require = "">
8 + <input type = "sumbit" value = "Login" class = "btnLogin">
9 + <a href="/api/auth/kakao">
10 + <div class = "kakaoLogin">
11 + 카카오 계정으로 로그인
12 + </div>
13 + </a>
14 + </fieldset>
15 + </form>
16 + <%}else{%>
17 + <div class = "memberInfo"}>
18 + <p><a href="/logout" onclick="return confirm('로그아웃??')">LOGOUT</a></p>
19 + </div>
20 + <%}%>
21 +</div>
22 +
23 +<script type = "text/javaScript">
24 + (function()){
25 + $(document.)
26 + }