Showing
7 changed files
with
47 additions
and
7 deletions
1 | import React from "react"; | 1 | import React from "react"; |
2 | import { Typography, Form, Input, Icon, Button} from 'antd'; | 2 | import { Typography, Form, Input, Icon, Button} from 'antd'; |
3 | import { withRouter } from "react-router-dom"; | 3 | import { withRouter } from "react-router-dom"; |
4 | +import Axios from 'axios'; | ||
5 | + | ||
4 | const { Title } = Typography; | 6 | const { Title } = Typography; |
7 | +const email = document.getElementById('email'); | ||
8 | +const pw = document.getElementById('password'); | ||
9 | + | ||
10 | +async function login() { | ||
11 | + | ||
12 | + var LoginForm = document.loginForm; | ||
13 | + if(email && pw){ | ||
14 | + const info = { | ||
15 | + email, | ||
16 | + pw | ||
17 | + } | ||
18 | + | ||
19 | + const response = await Axios.post('/users/login', info) | ||
20 | + if(response){ | ||
21 | + LoginForm.action = `/chat?${response}`; | ||
22 | + LoginForm.loginForm.submit(); | ||
23 | + } | ||
24 | + } | ||
25 | +} | ||
5 | 26 | ||
6 | 27 | ||
7 | function loginpage() { | 28 | function loginpage() { |
29 | + | ||
8 | return ( | 30 | return ( |
9 | <div> | 31 | <div> |
10 | <div style={{ display: 'flex', justifyContent: 'center', marginTop: '1rem', paddingTop: '10rem' }}> | 32 | <div style={{ display: 'flex', justifyContent: 'center', marginTop: '1rem', paddingTop: '10rem' }}> |
11 | <Title level={2}>Login Page</Title> | 33 | <Title level={2}>Login Page</Title> |
12 | </div> | 34 | </div> |
13 | <div style={{ display: 'flex', justifyContent: 'center', marginTop: '1rem'}}> | 35 | <div style={{ display: 'flex', justifyContent: 'center', marginTop: '1rem'}}> |
14 | - <form style={{ width: '350px' }}> | 36 | + <form style={{ width: '350px' }} name = "loginForm"> |
15 | <Form.Item required> | 37 | <Form.Item required> |
16 | <Input | 38 | <Input |
17 | id="email" | 39 | id="email" |
... | @@ -32,9 +54,9 @@ function loginpage() { | ... | @@ -32,9 +54,9 @@ function loginpage() { |
32 | 54 | ||
33 | <Form.Item> | 55 | <Form.Item> |
34 | <div> | 56 | <div> |
35 | - <Button type="primary" htmlType="submit" className="login-form-button" style={{ minWidth: '100%' }}> | 57 | + <Button type="primary" htmlType="submit" className="login-form-button" style={{ minWidth: '100%' }} onClick={login}> |
36 | Log in | 58 | Log in |
37 | - </Button> | 59 | + </Button> |
38 | </div> | 60 | </div> |
39 | <a href="/register">가입하기</a> Or <a href = "/chat"> 비회원으로 사용하기 </a> | 61 | <a href="/register">가입하기</a> Or <a href = "/chat"> 비회원으로 사용하기 </a> |
40 | </Form.Item> | 62 | </Form.Item> | ... | ... |
... | @@ -8,6 +8,7 @@ const config = require("./server/config/keys"); | ... | @@ -8,6 +8,7 @@ const config = require("./server/config/keys"); |
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 | ||
11 | +app.use('/users/login',require('./server/routes/users/login')); | ||
11 | app.use('/api/dialogflow', require('./server/routes/dialogflow')); | 12 | app.use('/api/dialogflow', require('./server/routes/dialogflow')); |
12 | app.use('/api/latest',require('./server/routes/latest')); | 13 | app.use('/api/latest',require('./server/routes/latest')); |
13 | app.use('/api/related',require('./server/routes/related')); | 14 | app.use('/api/related',require('./server/routes/related')); | ... | ... |
... | @@ -2,7 +2,6 @@ const express = require('express'); | ... | @@ -2,7 +2,6 @@ const express = require('express'); |
2 | const router = express.Router(); | 2 | const router = express.Router(); |
3 | const structjson = require('./structjson.js'); | 3 | const structjson = require('./structjson.js'); |
4 | const dialogflow = require('dialogflow'); | 4 | const dialogflow = require('dialogflow'); |
5 | -const uuid = require('uuid'); | ||
6 | 5 | ||
7 | const config = require('../config/keys'); | 6 | const config = require('../config/keys'); |
8 | 7 | ... | ... |
1 | const express = require('express'); | 1 | const express = require('express'); |
2 | const router = express.Router(); | 2 | const router = express.Router(); |
3 | -const uuid = require('uuid'); //uuid 제대로 이해하고 다시 작성하기. | ||
4 | 3 | ||
5 | const axios = require('axios'); | 4 | const axios = require('axios'); |
6 | const cheerio = require('cheerio'); | 5 | const cheerio = require('cheerio'); | ... | ... |
1 | const express = require('express'); | 1 | const express = require('express'); |
2 | const router = express.Router(); | 2 | const router = express.Router(); |
3 | -const uuid = require('uuid'); //uuid 제대로 이해하고 다시 작성하기. | ||
4 | 3 | ||
5 | const axios = require('axios'); | 4 | const axios = require('axios'); |
6 | const cheerio = require('cheerio'); | 5 | const cheerio = require('cheerio'); | ... | ... |
1 | const express = require('express'); | 1 | const express = require('express'); |
2 | const router = express.Router(); | 2 | const router = express.Router(); |
3 | -const uuid = require('uuid'); //uuid 제대로 이해하고 다시 작성하기. | ||
4 | 3 | ||
5 | const axios = require('axios'); | 4 | const axios = require('axios'); |
6 | const cheerio = require('cheerio'); | 5 | const cheerio = require('cheerio'); | ... | ... |
1 | +const express = require('express'); | ||
2 | +const router = express.Router(); | ||
3 | + | ||
4 | +var user = { | ||
5 | + email: "mathmjseo@khu.ac.kr", | ||
6 | + name: "minjeong", | ||
7 | + pw: "1234", | ||
8 | + keyword: "오마이걸" | ||
9 | +} | ||
10 | + | ||
11 | +router.post('/users/login', async(req,res)=>{ | ||
12 | + const userEmail = req.body.email; | ||
13 | + const userPW = req.body.pw; | ||
14 | + const data = ""; | ||
15 | + if(userEmail === user.email && ueserPW === user.pw){ | ||
16 | + data = user.keyword; | ||
17 | + } | ||
18 | + res.send(data); | ||
19 | +}) | ||
20 | + | ||
21 | +module.exports = router; | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment