서민정

remove gcp files and update user

1 -# This file specifies files that are *not* uploaded to Google Cloud Platform
2 -# using gcloud. It follows the same syntax as .gitignore, with the addition of
3 -# "#!include" directives (which insert the entries of the given .gitignore-style
4 -# file at that point).
5 -#
6 -# For more information, run:
7 -# $ gcloud topic gcloudignore
8 -#
9 -.gcloudignore
10 -# If you would like to upload your .git directory, .gitignore file or files
11 -# from your .gitignore file, remove the corresponding line
12 -# below:
13 -.git
14 -.gitignore
15 -
16 -# Node.js dependencies:
17 -node_modules/
18 -
19 -/node_modules
20 -/build
21 -/client/node_modules
22 -
23 -.DS_Store
24 -
25 -npm-debug.log*
26 -yarn-debug.log*
27 -yarn-error.log*
28 -
29 -.vscode
30 -
31 -dev.js
32 -./server/config/dev.js
...@@ -11,4 +11,6 @@ yarn-error.log* ...@@ -11,4 +11,6 @@ yarn-error.log*
11 .vscode 11 .vscode
12 12
13 dev.js 13 dev.js
14 +auth.js
14 ./server/config/dev.js 15 ./server/config/dev.js
16 +./server/config/auth.js
......
...@@ -4,6 +4,4 @@ ...@@ -4,6 +4,4 @@
4 - 뉴스 크롤링 후 이미지 사이즈 80*80 인 것을 원본으로 변환할 수 있는 방법은..? 4 - 뉴스 크롤링 후 이미지 사이즈 80*80 인 것을 원본으로 변환할 수 있는 방법은..?
5 - 구글 [Cloud Authentication](https://cloud.google.com/docs/authentication/getting-started?hl=ko) 으로 사용해서 로컬에서 실행시키는데, 5 - 구글 [Cloud Authentication](https://cloud.google.com/docs/authentication/getting-started?hl=ko) 으로 사용해서 로컬에서 실행시키는데,
6 만약 배포를 해야한다면 이 부분은 어떻게 해야할지 ..? 6 만약 배포를 해야한다면 이 부분은 어떻게 해야할지 ..?
7 -- 사용자 인증 기능 추가 -> 회원 등록 시 관심가수를 입력받아서 로그인 할 때마다 최신 & 정확 & 소식 을 전달해줌 / 비회원으로도 이용가능_지금과 같이
8 ---> React Router 사용해서 /<> 에 따라서 login/register/chatpage 가 되도록 구현해야함.
9 - -> 로그인,회원가입 페이지는 Boiler-plate 사용하기.............................도전
...\ No newline at end of file ...\ No newline at end of file
7 +- 회원으로 로그인 했을 때, 주어진 키워드로 챗봇이 "먼저 검색"해줄 수 있도록 설정하는 방법은?!
......
1 -# Copyright 2017, Google, Inc.
2 -# Licensed under the Apache License, Version 2.0 (the "License");
3 -# you may not use this file except in compliance with the License.
4 -# You may obtain a copy of the License at
5 -#
6 -# http://www.apache.org/licenses/LICENSE-2.0
7 -#
8 -# Unless required by applicable law or agreed to in writing, software
9 -# distributed under the License is distributed on an "AS IS" BASIS,
10 -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 -# See the License for the specific language governing permissions and
12 -# limitations under the License.
13 -
14 -# [START gae_flex_quickstart_yaml]
15 -runtime: nodejs10
16 -
17 -# This sample incurs costs to run on the App Engine flexible environment.
18 -# The settings below are to reduce costs during testing and are not appropriate
19 -# for production use. For more information, see:
20 -# https://cloud.google.com/appengine/docs/flexible/nodejs/configuring-your-app-with-app-yaml
21 -
22 -
23 -# [END gae_flex_quickstart_yaml]
1 -# Copyright 2017, Google, Inc.
2 -# Licensed under the Apache License, Version 2.0 (the "License");
3 -# you may not use this file except in compliance with the License.
4 -# You may obtain a copy of the License at
5 -#
6 -# http://www.apache.org/licenses/LICENSE-2.0
7 -#
8 -# Unless required by applicable law or agreed to in writing, software
9 -# distributed under the License is distributed on an "AS IS" BASIS,
10 -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 -# See the License for the specific language governing permissions and
12 -# limitations under the License.
13 -
14 -# [START gae_flex_quickstart_yaml]
15 -runtime: nodejs10
16 -
17 -
18 -# [END gae_flex_quickstart_yaml]
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
4 "private": true, 4 "private": true,
5 "engines": { 5 "engines": {
6 "node": "10.x.x", 6 "node": "10.x.x",
7 - "npm": "6.13.4" 7 + "npm": "6.x",
8 + "yarn" : ">=1.0.0 <2.0.0"
8 }, 9 },
9 "dependencies": { 10 "dependencies": {
10 "antd": "^3.26.5", 11 "antd": "^3.26.5",
......
...@@ -6,24 +6,54 @@ import Message from './Sections/Message'; ...@@ -6,24 +6,54 @@ import Message from './Sections/Message';
6 import { List, Icon, Avatar } from 'antd'; 6 import { List, Icon, Avatar } from 'antd';
7 import Card from "./Sections/Card"; 7 import Card from "./Sections/Card";
8 import CheckString from './Check'; 8 import CheckString from './Check';
9 -const username = "유저";
10 9
11 -function getKeyword(){ 10 +function getUserInfo(){
12 let url = window.location.href; 11 let url = window.location.href;
13 let keyword = ""; 12 let keyword = "";
13 + let name = "";
14 + let from = 0;
15 + let to = 0;
16 + let flag = false;
14 if(!url) return keyword; 17 if(!url) return keyword;
15 for(var i = 0; i <= url.length; i++){ 18 for(var i = 0; i <= url.length; i++){
19 + if(flag && url[i] === '&'){
20 + to = i;
21 + break;
22 + }
16 if(url[i] === '='){ 23 if(url[i] === '='){
17 - keyword = url.substr(i+1); 24 + from = i+1;
18 - keyword = decodeURI(keyword); 25 + flag = true;
19 - return keyword;
20 } 26 }
21 } 27 }
28 +
29 + keyword = url.substr(from,to-from);
30 + keyword = decodeURI(keyword);
31 + name = url.substr(to+6);
32 + name = decodeURI(name);
33 +
34 + var user = {
35 + keyword,
36 + name
37 + };
38 +
39 + return user;
40 +}
41 +
42 +const user = getUserInfo();
43 +let username = "유저";
44 +let userKeyword = "";
45 +
46 +if(user.keyword){
47 + userKeyword = user.keyword;
48 + username = user.name;
22 } 49 }
23 50
24 -let userKeyword = getKeyword();
25 51
26 function Chatbot() { 52 function Chatbot() {
53 + console.log("이름",username);
54 + console.log("키워드",userKeyword);
55 + var isUser = false;
56 + if(userKeyword) isUser = true;
27 const dispatch = useDispatch(); 57 const dispatch = useDispatch();
28 const messagesFromRedux = useSelector(state => state.message.messages) 58 const messagesFromRedux = useSelector(state => state.message.messages)
29 59
...@@ -31,12 +61,11 @@ function Chatbot() { ...@@ -31,12 +61,11 @@ function Chatbot() {
31 61
32 eventQuery('001_Welcome') 62 eventQuery('001_Welcome')
33 .then(eventQuery('002_Intro')) 63 .then(eventQuery('002_Intro'))
64 +
34 65
35 }, []) 66 }, [])
36 67
37 -
38 const textQuery = async (text) => { 68 const textQuery = async (text) => {
39 -
40 // First Need to take care of the message I sent 69 // First Need to take care of the message I sent
41 let conversation = { 70 let conversation = {
42 who: username, 71 who: username,
...@@ -116,7 +145,7 @@ function Chatbot() { ...@@ -116,7 +145,7 @@ function Chatbot() {
116 } 145 }
117 146
118 } 147 }
119 - 148 +
120 const eventQuery = async (event) => { 149 const eventQuery = async (event) => {
121 150
122 // We need to take care of the message Chatbot sent 151 // We need to take care of the message Chatbot sent
......
...@@ -3,4 +3,5 @@ const proxy = require("http-proxy-middleware"); ...@@ -3,4 +3,5 @@ const proxy = require("http-proxy-middleware");
3 module.exports = function(app) { 3 module.exports = function(app) {
4 app.use(proxy("/api", { target: "http://localhost:5000/" })); 4 app.use(proxy("/api", { target: "http://localhost:5000/" }));
5 5
6 -};
...\ No newline at end of file ...\ No newline at end of file
6 +};
7 +//http://localhost:5000/
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -17,10 +17,12 @@ const userInfo = async (info) => { ...@@ -17,10 +17,12 @@ const userInfo = async (info) => {
17 } 17 }
18 18
19 const response = await Axios.post('/api/login/userInfo', userVariables); 19 const response = await Axios.post('/api/login/userInfo', userVariables);
20 - if(response.data){ 20 + if(response.data != 'FAIL'){
21 // loginForm.action = `/chat?${response.data}`; 21 // loginForm.action = `/chat?${response.data}`;
22 // loginForm.submit(); 22 // loginForm.submit();
23 - window.location.href=`/chat?keyword=${response.data}`; 23 + var keyword = response.data.keyword;
24 + var name = response.data.name;
25 + window.location.href=`/chat?keyword=${keyword}&name=${name}`;
24 } else{ 26 } else{
25 alert("입력하신 정보와 일치하는 회원이 존재하지 않습니다 😥"); 27 alert("입력하신 정보와 일치하는 회원이 존재하지 않습니다 😥");
26 } 28 }
......
...@@ -2,9 +2,9 @@ const express = require("express"); ...@@ -2,9 +2,9 @@ const express = require("express");
2 const path = require("path"); 2 const path = require("path");
3 const bodyParser = require("body-parser"); 3 const bodyParser = require("body-parser");
4 const app = express(); 4 const app = express();
5 -
6 const config = require("./server/config/keys"); 5 const config = require("./server/config/keys");
7 6
7 +app.set('trust proxy',true);
8 app.use(bodyParser.urlencoded({ extended: true })); 8 app.use(bodyParser.urlencoded({ extended: true }));
9 app.use(bodyParser.json()); 9 app.use(bodyParser.json());
10 10
...@@ -32,3 +32,6 @@ const port = process.env.PORT || 5000; ...@@ -32,3 +32,6 @@ const port = process.env.PORT || 5000;
32 app.listen(port, () => { 32 app.listen(port, () => {
33 console.log(`Server Running at ${port}`) 33 console.log(`Server Running at ${port}`)
34 }); 34 });
35 +
36 +
37 +// res.sendFile(path.resolve(__dirname, "client", "build", "index.html"));
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
4 "description": "chatbot-app", 4 "description": "chatbot-app",
5 "main": "index.js", 5 "main": "index.js",
6 "engines": { 6 "engines": {
7 - "node": "10.x.x", 7 + "node": "10.x",
8 - "npm": "6.13.4" 8 + "npm": "6.x"
9 }, 9 },
10 "scripts": { 10 "scripts": {
11 "start": "node index.js", 11 "start": "node index.js",
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
19 ], 19 ],
20 "license": "ISC", 20 "license": "ISC",
21 "dependencies": { 21 "dependencies": {
22 - "@google-cloud/bigquery": "^4.7.0",
23 "actions-on-google": "^2.12.0", 22 "actions-on-google": "^2.12.0",
24 "axios": "^0.19.2", 23 "axios": "^0.19.2",
25 "body-parser": "^1.18.3", 24 "body-parser": "^1.18.3",
......
...@@ -20,6 +20,10 @@ router.post('/userInfo', async(req,res)=>{ ...@@ -20,6 +20,10 @@ router.post('/userInfo', async(req,res)=>{
20 }; 20 };
21 21
22 result = getUser(simpleUserInfo); 22 result = getUser(simpleUserInfo);
23 + if(typeof(result) === 'undefined'){
24 + result = 'FAIL'
25 + }
26 + console.log("RESULT",result)
23 res.send(result); 27 res.send(result);
24 }) 28 })
25 29
......
...@@ -24,10 +24,13 @@ function addUser(userInfo){ ...@@ -24,10 +24,13 @@ function addUser(userInfo){
24 function getUser(simpleUserInfo){ 24 function getUser(simpleUserInfo){
25 let userEmail = simpleUserInfo.email; 25 let userEmail = simpleUserInfo.email;
26 let userPw = simpleUserInfo.pw; 26 let userPw = simpleUserInfo.pw;
27 - let result = ""; 27 + let result;
28 for(var i = 0; i < users.length; i++){ 28 for(var i = 0; i < users.length; i++){
29 if(userEmail === users[i].email && userPw === users[i].pw){ 29 if(userEmail === users[i].email && userPw === users[i].pw){
30 - result = users[i].keyword; 30 + result = {
31 + "name":users[i].name,
32 + "keyword":users[i].keyword
33 + }
31 } 34 }
32 } 35 }
33 36
......