서민정

update login function but need to modify git add .!

import React from "react";
import { Typography, Form, Input, Icon, Button} from 'antd';
import { withRouter } from "react-router-dom";
import Axios from 'axios';
const { Title } = Typography;
const email = document.getElementById('email');
const pw = document.getElementById('password');
async function login() {
var LoginForm = document.loginForm;
if(email && pw){
const info = {
email,
pw
}
const response = await Axios.post('/users/login', info)
if(response){
LoginForm.action = `/chat?${response}`;
LoginForm.loginForm.submit();
}
}
}
function loginpage() {
return (
<div>
<div style={{ display: 'flex', justifyContent: 'center', marginTop: '1rem', paddingTop: '10rem' }}>
<Title level={2}>Login Page</Title>
</div>
<div style={{ display: 'flex', justifyContent: 'center', marginTop: '1rem'}}>
<form style={{ width: '350px' }}>
<form style={{ width: '350px' }} name = "loginForm">
<Form.Item required>
<Input
id="email"
......@@ -32,7 +54,7 @@ function loginpage() {
<Form.Item>
<div>
<Button type="primary" htmlType="submit" className="login-form-button" style={{ minWidth: '100%' }}>
<Button type="primary" htmlType="submit" className="login-form-button" style={{ minWidth: '100%' }} onClick={login}>
Log in
</Button>
</div>
......
......@@ -8,6 +8,7 @@ const config = require("./server/config/keys");
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use('/users/login',require('./server/routes/users/login'));
app.use('/api/dialogflow', require('./server/routes/dialogflow'));
app.use('/api/latest',require('./server/routes/latest'));
app.use('/api/related',require('./server/routes/related'));
......
......@@ -2,7 +2,6 @@ const express = require('express');
const router = express.Router();
const structjson = require('./structjson.js');
const dialogflow = require('dialogflow');
const uuid = require('uuid');
const config = require('../config/keys');
......
const express = require('express');
const router = express.Router();
const uuid = require('uuid'); //uuid 제대로 이해하고 다시 작성하기.
const axios = require('axios');
const cheerio = require('cheerio');
......
const express = require('express');
const router = express.Router();
const uuid = require('uuid'); //uuid 제대로 이해하고 다시 작성하기.
const axios = require('axios');
const cheerio = require('cheerio');
......
const express = require('express');
const router = express.Router();
const uuid = require('uuid'); //uuid 제대로 이해하고 다시 작성하기.
const axios = require('axios');
const cheerio = require('cheerio');
......
const express = require('express');
const router = express.Router();
var user = {
email: "mathmjseo@khu.ac.kr",
name: "minjeong",
pw: "1234",
keyword: "오마이걸"
}
router.post('/users/login', async(req,res)=>{
const userEmail = req.body.email;
const userPW = req.body.pw;
const data = "";
if(userEmail === user.email && ueserPW === user.pw){
data = user.keyword;
}
res.send(data);
})
module.exports = router;
\ No newline at end of file
......