Showing
7 changed files
with
110 additions
and
28 deletions
1 | const proxy = require("http-proxy-middleware"); | 1 | const proxy = require("http-proxy-middleware"); |
2 | 2 | ||
3 | module.exports = function(app) { | 3 | module.exports = function(app) { |
4 | + app.use(proxy("/api", { target: "http://localhost:5000/" })); | ||
4 | 5 | ||
5 | - app.use(proxy("/api", { target: "https://oss-chatbot-app.ue.r.appspot.com" })); | ||
6 | - | ||
7 | -}; | ||
8 | -// target: "http://localhost:5000/" | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
6 | +}; | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -17,14 +17,16 @@ const userInfo = async (info) => { | ... | @@ -17,14 +17,16 @@ 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){ |
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 | window.location.href=`/chat?keyword=${response.data}`; |
24 | + } else{ | ||
25 | + alert("입력하신 정보와 일치하는 회원이 존재하지 않습니다 😥"); | ||
24 | } | 26 | } |
25 | } | 27 | } |
26 | else{ | 28 | else{ |
27 | - alert("nothing"); | 29 | + alert("이메일과 패스워드를 입력해주세요!"); |
28 | } | 30 | } |
29 | } | 31 | } |
30 | 32 | ... | ... |
1 | import React from "react"; | 1 | import React from "react"; |
2 | import { Typography, Form, Input, Button} from 'antd'; | 2 | import { Typography, Form, Input, Button} from 'antd'; |
3 | import { withRouter } from "react-router-dom"; | 3 | import { withRouter } from "react-router-dom"; |
4 | +import Axios from "axios"; | ||
4 | const { Title } = Typography; | 5 | const { Title } = Typography; |
5 | 6 | ||
7 | +const saveUser = async (info) => { | ||
8 | + const name = document.getElementById('name').value; | ||
9 | + const email = document.getElementById('email').value; | ||
10 | + const pw = document.getElementById('password').value; | ||
11 | + const keyword = document.getElementById('keyword').value; | ||
12 | + | ||
13 | + if(name && email && pw && keyword){ | ||
14 | + const userVariable = { | ||
15 | + name, | ||
16 | + email, | ||
17 | + pw, | ||
18 | + keyword | ||
19 | + } | ||
20 | + | ||
21 | + const response = await Axios.post('/api/register/addUser', userVariable); | ||
22 | + if(response.data === 'SUCCESS'){ | ||
23 | + alert(`${name}님, 회원가입이 완료되었습니다!`); | ||
24 | + window.location.href = `/`; | ||
25 | + } | ||
26 | + else if(response.data === 'EXIST'){ | ||
27 | + alert("같은 email을 가진 회원이 존재합니다 😥"); | ||
28 | + } | ||
29 | + } else{ | ||
30 | + alert('모든 정보를 입력해주세요!'); | ||
31 | + } | ||
32 | +} | ||
6 | 33 | ||
7 | function registerpage() { | 34 | function registerpage() { |
8 | return ( | 35 | return ( |
... | @@ -45,7 +72,7 @@ function registerpage() { | ... | @@ -45,7 +72,7 @@ function registerpage() { |
45 | </Form.Item> | 72 | </Form.Item> |
46 | 73 | ||
47 | <Form.Item> | 74 | <Form.Item> |
48 | - <Button type="primary"> | 75 | + <Button type="primary" onClick = {saveUser}> |
49 | Submit | 76 | Submit |
50 | </Button> | 77 | </Button> |
51 | </Form.Item> | 78 | </Form.Item> |
... | @@ -53,13 +80,6 @@ function registerpage() { | ... | @@ -53,13 +80,6 @@ function registerpage() { |
53 | </div> | 80 | </div> |
54 | </div> | 81 | </div> |
55 | ); | 82 | ); |
56 | - // return ( | ||
57 | - // <div> | ||
58 | - // <div style={{ display: 'flex', justifyContent: 'center', marginTop: '1rem' }}> | ||
59 | - // <Title level={2} >RegisterPage Test</Title> | ||
60 | - // </div> | ||
61 | - // </div> | ||
62 | - // ) | ||
63 | } | 83 | } |
64 | 84 | ||
65 | export default withRouter(registerpage); | 85 | export default withRouter(registerpage); |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -9,6 +9,7 @@ app.use(bodyParser.urlencoded({ extended: true })); | ... | @@ -9,6 +9,7 @@ app.use(bodyParser.urlencoded({ extended: true })); |
9 | app.use(bodyParser.json()); | 9 | app.use(bodyParser.json()); |
10 | 10 | ||
11 | app.use('/api/login',require('./server/routes/users/login')); | 11 | app.use('/api/login',require('./server/routes/users/login')); |
12 | +app.use('/api/register',require('./server/routes/users/register')); | ||
12 | app.use('/api/dialogflow', require('./server/routes/dialogflow')); | 13 | app.use('/api/dialogflow', require('./server/routes/dialogflow')); |
13 | app.use('/api/latest',require('./server/routes/latest')); | 14 | app.use('/api/latest',require('./server/routes/latest')); |
14 | app.use('/api/related',require('./server/routes/related')); | 15 | app.use('/api/related',require('./server/routes/related')); | ... | ... |
1 | const express = require('express'); | 1 | const express = require('express'); |
2 | const router = express.Router(); | 2 | const router = express.Router(); |
3 | +var getUser = require('./user').getUser; | ||
3 | 4 | ||
4 | -var user = { | 5 | +// var user = { |
5 | - email: "mathmjseo@khu.ac.kr", | 6 | +// email: "mathmjseo@khu.ac.kr", |
6 | - name: "minjeong", | 7 | +// name: "minjeong", |
7 | - pw: "1234", | 8 | +// pw: "1234", |
8 | - keyword: "오마이걸" | 9 | +// keyword: "오마이걸" |
9 | -} | 10 | +// } |
10 | 11 | ||
11 | router.post('/userInfo', async(req,res)=>{ | 12 | router.post('/userInfo', async(req,res)=>{ |
12 | let userEmail = req.body.email; | 13 | let userEmail = req.body.email; |
13 | - console.log(userEmail); | ||
14 | let userPW = req.body.pw; | 14 | let userPW = req.body.pw; |
15 | - console.log(userPW); | 15 | + let result = ""; |
16 | - let data = ""; | 16 | + |
17 | - if(userEmail === user.email && userPW === user.pw){ | 17 | + const simpleUserInfo = { |
18 | - data = user.keyword; | 18 | + email: userEmail, |
19 | - console.log(data); | 19 | + pw: userPW |
20 | - } | 20 | + }; |
21 | - res.send(data); | 21 | + |
22 | + result = getUser(simpleUserInfo); | ||
23 | + res.send(result); | ||
22 | }) | 24 | }) |
23 | 25 | ||
24 | module.exports = router; | 26 | module.exports = router; |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | +const express = require('express'); | ||
2 | +const router = express.Router(); | ||
3 | +var addUser = require('./user').addUser; | ||
4 | + | ||
5 | +router.post('/addUser', async(req,res)=>{ | ||
6 | + const userName = req.body.name; | ||
7 | + const userEmail = req.body.email; | ||
8 | + const userPW = req.body.pw; | ||
9 | + const userKeyword = req.body.keyword; | ||
10 | + | ||
11 | + const newUser = { | ||
12 | + 'name':userName, | ||
13 | + 'email':userEmail, | ||
14 | + 'pw' :userPW, | ||
15 | + 'keyword': userKeyword | ||
16 | + }; | ||
17 | + | ||
18 | + var result = addUser(newUser); | ||
19 | + res.send(result); | ||
20 | +}) | ||
21 | + | ||
22 | +module.exports = router; | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
server/routes/users/user.js
0 → 100644
1 | +let users = new Array(); | ||
2 | + | ||
3 | +function addUser(userInfo){ | ||
4 | + let result = ""; | ||
5 | + let isExist = false; | ||
6 | + for(var i = 0; i < users.length; i++){ | ||
7 | + if(users[i].email === userInfo.email){ | ||
8 | + isExist = true; | ||
9 | + break; | ||
10 | + } | ||
11 | + } | ||
12 | + | ||
13 | + if(!isExist){ | ||
14 | + users.push(userInfo); | ||
15 | + result = "SUCCESS"; | ||
16 | + } | ||
17 | + else{ | ||
18 | + result = "EXIST"; | ||
19 | + } | ||
20 | + | ||
21 | + return result; | ||
22 | +} | ||
23 | + | ||
24 | +function getUser(simpleUserInfo){ | ||
25 | + let userEmail = simpleUserInfo.email; | ||
26 | + let userPw = simpleUserInfo.pw; | ||
27 | + let result = ""; | ||
28 | + for(var i = 0; i < users.length; i++){ | ||
29 | + if(userEmail === users[i].email && userPw === users[i].pw){ | ||
30 | + result = users[i].keyword; | ||
31 | + } | ||
32 | + } | ||
33 | + | ||
34 | + return result; | ||
35 | +} | ||
36 | + | ||
37 | +module.exports = {addUser, getUser}; |
-
Please register or login to post a comment