Toggle navigation
Toggle navigation
This project
Loading...
Sign in
서민정
/
SEARCH-AND-CHAT
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
2
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
서민정
2020-06-06 20:04:51 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5a904e8649a375fb7effd3f9b0cd5c057ba3960d
5a904e86
1 parent
c47beadd
update register
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
110 additions
and
28 deletions
client/src/setupProxy.js
client/src/views/loginpage.js
client/src/views/registerpage.js
index.js
server/routes/users/login.js
server/routes/users/register.js
server/routes/users/user.js
client/src/setupProxy.js
View file @
5a904e8
const
proxy
=
require
(
"http-proxy-middleware"
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
proxy
(
"/api"
,
{
target
:
"http://localhost:5000/"
}));
app
.
use
(
proxy
(
"/api"
,
{
target
:
"https://oss-chatbot-app.ue.r.appspot.com"
}));
};
// target: "http://localhost:5000/"
\ No newline at end of file
};
\ No newline at end of file
...
...
client/src/views/loginpage.js
View file @
5a904e8
...
...
@@ -17,14 +17,16 @@ const userInfo = async (info) => {
}
const
response
=
await
Axios
.
post
(
'/api/login/userInfo'
,
userVariables
);
if
(
response
.
data
===
"오마이걸"
){
if
(
response
.
data
){
// loginForm.action = `/chat?${response.data}`;
// loginForm.submit();
window
.
location
.
href
=
`/chat?keyword=
${
response
.
data
}
`
;
}
else
{
alert
(
"입력하신 정보와 일치하는 회원이 존재하지 않습니다 😥"
);
}
}
else
{
alert
(
"
nothing
"
);
alert
(
"
이메일과 패스워드를 입력해주세요!
"
);
}
}
...
...
client/src/views/registerpage.js
View file @
5a904e8
import
React
from
"react"
;
import
{
Typography
,
Form
,
Input
,
Button
}
from
'antd'
;
import
{
withRouter
}
from
"react-router-dom"
;
import
Axios
from
"axios"
;
const
{
Title
}
=
Typography
;
const
saveUser
=
async
(
info
)
=>
{
const
name
=
document
.
getElementById
(
'name'
).
value
;
const
email
=
document
.
getElementById
(
'email'
).
value
;
const
pw
=
document
.
getElementById
(
'password'
).
value
;
const
keyword
=
document
.
getElementById
(
'keyword'
).
value
;
if
(
name
&&
email
&&
pw
&&
keyword
){
const
userVariable
=
{
name
,
email
,
pw
,
keyword
}
const
response
=
await
Axios
.
post
(
'/api/register/addUser'
,
userVariable
);
if
(
response
.
data
===
'SUCCESS'
){
alert
(
`
${
name
}
님, 회원가입이 완료되었습니다!`
);
window
.
location
.
href
=
`/`
;
}
else
if
(
response
.
data
===
'EXIST'
){
alert
(
"같은 email을 가진 회원이 존재합니다 😥"
);
}
}
else
{
alert
(
'모든 정보를 입력해주세요!'
);
}
}
function
registerpage
()
{
return
(
...
...
@@ -45,7 +72,7 @@ function registerpage() {
<
/Form.Item
>
<
Form
.
Item
>
<
Button
type
=
"primary"
>
<
Button
type
=
"primary"
onClick
=
{
saveUser
}
>
Submit
<
/Button
>
<
/Form.Item
>
...
...
@@ -53,13 +80,6 @@ function registerpage() {
<
/div
>
<
/div>
);
// return (
// <div>
// <div style={{ display: 'flex', justifyContent: 'center', marginTop: '1rem' }}>
// <Title level={2} >RegisterPage Test</Title>
// </div>
// </div>
// )
}
export
default
withRouter
(
registerpage
);
\ No newline at end of file
...
...
index.js
View file @
5a904e8
...
...
@@ -9,6 +9,7 @@ app.use(bodyParser.urlencoded({ extended: true }));
app
.
use
(
bodyParser
.
json
());
app
.
use
(
'/api/login'
,
require
(
'./server/routes/users/login'
));
app
.
use
(
'/api/register'
,
require
(
'./server/routes/users/register'
));
app
.
use
(
'/api/dialogflow'
,
require
(
'./server/routes/dialogflow'
));
app
.
use
(
'/api/latest'
,
require
(
'./server/routes/latest'
));
app
.
use
(
'/api/related'
,
require
(
'./server/routes/related'
));
...
...
server/routes/users/login.js
View file @
5a904e8
const
express
=
require
(
'express'
);
const
router
=
express
.
Router
();
var
getUser
=
require
(
'./user'
).
getUser
;
var
user
=
{
email
:
"mathmjseo@khu.ac.kr"
,
name
:
"minjeong"
,
pw
:
"1234"
,
keyword
:
"오마이걸"
}
//
var user = {
//
email: "mathmjseo@khu.ac.kr",
//
name: "minjeong",
//
pw: "1234",
//
keyword: "오마이걸"
//
}
router
.
post
(
'/userInfo'
,
async
(
req
,
res
)
=>
{
let
userEmail
=
req
.
body
.
email
;
console
.
log
(
userEmail
);
let
userPW
=
req
.
body
.
pw
;
console
.
log
(
userPW
);
let
data
=
""
;
if
(
userEmail
===
user
.
email
&&
userPW
===
user
.
pw
){
data
=
user
.
keyword
;
console
.
log
(
data
);
}
res
.
send
(
data
);
let
result
=
""
;
const
simpleUserInfo
=
{
email
:
userEmail
,
pw
:
userPW
};
result
=
getUser
(
simpleUserInfo
);
res
.
send
(
result
);
})
module
.
exports
=
router
;
\ No newline at end of file
...
...
server/routes/users/register.js
View file @
5a904e8
const
express
=
require
(
'express'
);
const
router
=
express
.
Router
();
var
addUser
=
require
(
'./user'
).
addUser
;
router
.
post
(
'/addUser'
,
async
(
req
,
res
)
=>
{
const
userName
=
req
.
body
.
name
;
const
userEmail
=
req
.
body
.
email
;
const
userPW
=
req
.
body
.
pw
;
const
userKeyword
=
req
.
body
.
keyword
;
const
newUser
=
{
'name'
:
userName
,
'email'
:
userEmail
,
'pw'
:
userPW
,
'keyword'
:
userKeyword
};
var
result
=
addUser
(
newUser
);
res
.
send
(
result
);
})
module
.
exports
=
router
;
\ No newline at end of file
...
...
server/routes/users/user.js
0 → 100644
View file @
5a904e8
let
users
=
new
Array
();
function
addUser
(
userInfo
){
let
result
=
""
;
let
isExist
=
false
;
for
(
var
i
=
0
;
i
<
users
.
length
;
i
++
){
if
(
users
[
i
].
email
===
userInfo
.
email
){
isExist
=
true
;
break
;
}
}
if
(
!
isExist
){
users
.
push
(
userInfo
);
result
=
"SUCCESS"
;
}
else
{
result
=
"EXIST"
;
}
return
result
;
}
function
getUser
(
simpleUserInfo
){
let
userEmail
=
simpleUserInfo
.
email
;
let
userPw
=
simpleUserInfo
.
pw
;
let
result
=
""
;
for
(
var
i
=
0
;
i
<
users
.
length
;
i
++
){
if
(
userEmail
===
users
[
i
].
email
&&
userPw
===
users
[
i
].
pw
){
result
=
users
[
i
].
keyword
;
}
}
return
result
;
}
module
.
exports
=
{
addUser
,
getUser
};
Please
register
or
login
to post a comment