Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
shopping-mall
Commits
418d3466
Commit
418d3466
authored
Jan 08, 2021
by
이재연
Browse files
로그인수정중
parent
42b6aaf5
Changes
6
Hide whitespace changes
Inline
Side-by-side
client/src/Pages/Login.js
View file @
418d3466
import
React
,
{
useState
,
useEffect
,
useRef
}
from
'
react
'
;
import
React
,
{
useState
}
from
'
react
'
;
import
{
Link
,
Redirect
}
from
'
react-router-dom
'
;
import
Nav1
from
'
../Components/MainNav
'
;
import
Nav2
from
'
../Components/SubNav
'
;
...
...
@@ -30,17 +30,18 @@ function Login() {
setValidated
(
true
);
try
{
setError
(
''
)
await
axios
.
post
(
'
api/auth/login
'
,
user
)
await
axios
.
post
(
'
/
api/auth/login
'
,
user
)
handleLogin
()
setSuccess
(
true
)
}
catch
(
error
)
{
catchErrors
(
error
,
setError
)
console
.
log
(
error
)
}
if
(
success
)
{
}
if
(
success
)
{
return
<
Redirect
to
=
'
/
'
/>
}
}
function
handleChange
(
event
)
{
...
...
client/src/Pages/Logout.js
0 → 100644
View file @
418d3466
// import { Button } from 'bootstrap'
// import React from 'react'
// import { handleLogout } from '../utils/auth'
// function logout() {
// return (
// <div>
// <Button onClick={()=>handleLogout()}>Logout</Button>
// </div>
// )
// }
// export default logout
client/src/Pages/LogoutButton.js
deleted
100644 → 0
View file @
42b6aaf5
import
React
from
'
react
'
import
{
withRouter
}
from
'
react-router-dom
'
function
LogoutButton
({
logout
,
history
}){
const
handleClick
=
()
=>
{
logout
()
history
.
push
(
"
/
"
)
}
return
<
button
onClick
=
{
handleClick
}
>
Logout
<
/button
>
}
export
default
withRouter
(
LogoutButton
)
\ No newline at end of file
server/app.js
View file @
418d3466
...
...
@@ -23,7 +23,7 @@ app.use(express.static(path.join(process.cwd(), 'dist')))
// app.use('/', indexRouter);
app
.
use
(
'
/
'
,
kakaopayRoutes
)
app
.
use
(
'
/api/users
'
,
userRouter
)
app
.
use
(
'
/api/auth
/login
'
,
authRouter
)
app
.
use
(
'
/api/auth
'
,
authRouter
)
app
.
use
(
'
/api/products
'
,
productRouter
)
app
.
listen
(
config
.
port
,
()
=>
{
...
...
server/controllers/auth.controller.js
View file @
418d3466
...
...
@@ -9,7 +9,7 @@ const login = async(req,res)=>{
try
{
const
user
=
await
User
.
findOne
({
id
}).
select
(
'
+password
'
)
if
(
!
user
){
return
res
.
S
tatus
(
404
).
send
(
`
${
id
}
가 존재하지 않습니다.`
)
return
res
.
s
tatus
(
404
).
send
(
`
${
id
}
가 존재하지 않습니다.`
)
}
const
passwordMatch
=
await
bcrypt
.
compare
(
password
,
user
.
password
)
...
...
@@ -25,12 +25,17 @@ const login = async(req,res)=>{
})
res
.
send
(
'
로그인 되었습니다.
'
)
}
else
{
res
.
S
tatus
(
401
).
send
(
'
비밀번호가 일치하지 않습니다.
'
)
res
.
s
tatus
(
401
).
send
(
'
비밀번호가 일치하지 않습니다.
'
)
}
}
catch
(
error
){
console
.
log
(
error
)
res
.
S
tatus
(
500
).
send
(
'
로그인 실패. 다시 시도하세요.
'
)
res
.
s
tatus
(
500
).
send
(
'
로그인 실패. 다시 시도하세요.
'
)
}
}
// const logout =(req,res)=>{
// res.clearCookie('token')
// res.send('로그아웃 되었습니다.')
// }
export
default
{
login
}
\ No newline at end of file
server/routes/auth.routes.js
View file @
418d3466
...
...
@@ -3,7 +3,10 @@ import authCtrl from '../controllers/auth.controller.js';
const
router
=
express
.
Router
()
router
.
route
(
'
/
api/auth/
login
'
)
router
.
route
(
'
/login
'
)
.
post
(
authCtrl
.
login
)
// router.route('/logout')
// .get(authCtrl.logout)
export
default
router
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment