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-04 23:40:51 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
75e500e16b88139c3d6ce4595de44bad9cb510f6
75e500e1
1 parent
530bdb4b
Update login function
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
17 deletions
client/src/chatbot/chatbot.js
client/src/views/loginpage.js
index.js
server/routes/users/login.js
client/src/chatbot/chatbot.js
View file @
75e500e
...
...
@@ -8,6 +8,21 @@ import Card from "./Sections/Card";
import
CheckString
from
'./Check'
;
const
username
=
"유저"
;
function
getKeyword
(){
let
url
=
window
.
location
.
href
;
let
keyword
=
""
;
if
(
!
url
)
return
keyword
;
for
(
var
i
=
0
;
i
<=
url
.
length
;
i
++
){
if
(
url
[
i
]
===
'='
){
keyword
=
url
.
substr
(
i
+
1
);
keyword
=
decodeURI
(
keyword
);
return
keyword
;
}
}
}
let
userKeyword
=
getKeyword
();
function
Chatbot
()
{
const
dispatch
=
useDispatch
();
const
messagesFromRedux
=
useSelector
(
state
=>
state
.
message
.
messages
)
...
...
client/src/views/loginpage.js
View file @
75e500e
...
...
@@ -4,24 +4,28 @@ 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
()
{
console
.
log
(
"start"
);
var
LoginForm
=
document
.
loginForm
;
const
userInfo
=
async
(
info
)
=>
{
const
email
=
document
.
getElementById
(
'email'
).
value
;
const
pw
=
document
.
getElementById
(
'password'
).
value
;
if
(
email
&&
pw
){
const
info
=
{
const
userVariables
=
{
email
,
pw
}
const
response
=
await
Axios
.
post
(
'/users/login'
,
info
)
if
(
response
){
LoginForm
.
action
=
`/chat?
${
response
}
`
;
LoginForm
.
loginForm
.
submit
();
const
response
=
await
Axios
.
post
(
'/api/login/userInfo'
,
userVariables
);
if
(
response
.
data
===
"오마이걸"
){
// loginForm.action = `/chat?${response.data}`;
// loginForm.submit();
window
.
location
.
href
=
`/chat?keyword=
${
response
.
data
}
`
;
}
}
else
{
alert
(
"nothing"
);
}
}
...
...
@@ -54,7 +58,7 @@ function loginpage() {
<
Form
.
Item
>
<
div
>
<
Button
type
=
"primary"
htmlType
=
"submit"
className
=
"login-form-button"
style
=
{{
minWidth
:
'100%'
}}
onClick
=
{
login
}
>
<
Button
type
=
"primary"
className
=
"login-form-button"
style
=
{{
minWidth
:
'100%'
}}
onClick
=
{
userInfo
}
>
Log
in
<
/Button
>
<
/div
>
...
...
@@ -65,7 +69,7 @@ function loginpage() {
</div>
);
// return (
// htmlType="
submit
"
...
...
index.js
View file @
75e500e
...
...
@@ -8,7 +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
/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'
));
...
...
server/routes/users/login.js
View file @
75e500e
...
...
@@ -8,12 +8,15 @@ var user = {
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
){
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
);
})
...
...
Please
register
or
login
to post a comment