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
messenger
Commits
b84511b5
Commit
b84511b5
authored
Jan 08, 2021
by
우지원
Browse files
링크추가
parent
c748afc4
Changes
3
Show whitespace changes
Inline
Side-by-side
client/src/Components/Menu.js
View file @
b84511b5
import
React
from
'
react
'
import
React
from
'
react
'
import
{
Navbar
,
Nav
,
Button
}
from
'
react-bootstrap
'
;
import
{
Navbar
,
Nav
,
Button
}
from
'
react-bootstrap
'
;
import
{
Link
}
from
'
react-router-dom
'
;
import
{
handleLogout
}
from
'
../utils/auth
'
;
import
{
handleLogout
}
from
'
../utils/auth
'
;
function
Menu
()
{
function
Menu
()
{
...
@@ -14,7 +15,9 @@ function Menu() {
...
@@ -14,7 +15,9 @@ function Menu() {
<
Nav
.
Link
href
=
"
/profile
"
>
Profile
<
/Nav.Link
>
<
Nav
.
Link
href
=
"
/profile
"
>
Profile
<
/Nav.Link
>
<
Nav
.
Link
href
=
"
/hello
"
>
Hello
<
/Nav.Link
>
<
Nav
.
Link
href
=
"
/hello
"
>
Hello
<
/Nav.Link
>
<
/Nav
>
<
/Nav
>
<
Link
to
=
"
./login
"
>
<
Button
onClick
=
{()
=>
handleLogout
()}
variant
=
"
light
"
className
=
"
ml-3
"
>
Logout
<
/Button
>
<
Button
onClick
=
{()
=>
handleLogout
()}
variant
=
"
light
"
className
=
"
ml-3
"
>
Logout
<
/Button
>
<
/Link
>
<
/Navbar
>
<
/Navbar
>
)
)
}
}
...
...
client/src/Pages/SignUpPage.js
View file @
b84511b5
...
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';
...
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';
import
axios
from
'
axios
'
import
axios
from
'
axios
'
import
{
Button
,
Form
,
Container
,
Navbar
,
Alert
}
from
'
react-bootstrap
'
;
import
{
Button
,
Form
,
Container
,
Navbar
,
Alert
}
from
'
react-bootstrap
'
;
import
catchErrors
from
'
../utils/catchErrors
'
;
import
catchErrors
from
'
../utils/catchErrors
'
;
//
import { Redirect } from 'react-router-dom';
import
{
Redirect
}
from
'
react-router-dom
'
;
const
INIT_USER
=
{
const
INIT_USER
=
{
username
:
''
,
username
:
''
,
...
@@ -16,6 +16,7 @@ function SingUp() {
...
@@ -16,6 +16,7 @@ function SingUp() {
const
[
user
,
setUser
]
=
useState
(
INIT_USER
)
const
[
user
,
setUser
]
=
useState
(
INIT_USER
)
const
[
error
,
setError
]
=
useState
(
''
)
const
[
error
,
setError
]
=
useState
(
''
)
const
[
disabled
,
setDisabled
]
=
useState
(
true
)
const
[
disabled
,
setDisabled
]
=
useState
(
true
)
const
[
success
,
setSucces
]
=
useState
(
false
)
useEffect
(()
=>
{
useEffect
(()
=>
{
const
isUser
=
Object
.
values
(
user
).
every
(
el
=>
Boolean
(
el
))
const
isUser
=
Object
.
values
(
user
).
every
(
el
=>
Boolean
(
el
))
...
@@ -62,15 +63,16 @@ function SingUp() {
...
@@ -62,15 +63,16 @@ function SingUp() {
// ?????????hash 처리된 password가 저장되지 않았음
// ?????????hash 처리된 password가 저장되지 않았음
// setUser(INIT_USER)
// setUser(INIT_USER)
setSucces
(
true
)
}
catch
(
error
)
{
}
catch
(
error
)
{
catchErrors
(
error
,
setError
)
catchErrors
(
error
,
setError
)
}
}
}
}
//
if (success) {
if
(
success
)
{
//
console.log('success', success)
console
.
log
(
'
success
'
,
success
)
//
return <Redirect to='/login'/>
return
<
Redirect
to
=
'
/login
'
/>
//
}
}
return
(
return
(
...
...
server/controllers/auth.controller.js
View file @
b84511b5
...
@@ -49,14 +49,14 @@ const login = async (req, res) => {
...
@@ -49,14 +49,14 @@ const login = async (req, res) => {
}
catch
(
error
)
{
}
catch
(
error
)
{
//알수없는 모든 에러발생시 처리
//알수없는 모든 에러발생시 처리
console
.
log
(
error
)
console
.
log
(
error
)
res
.
status
(
500
).
send
(
'
로그인 에러
'
)
res
.
status
(
500
).
send
(
'
로그인 에러
가 발생하였습니다
'
)
}
}
}
}
const
logout
=
(
req
,
res
)
=>
{
const
logout
=
(
req
,
res
)
=>
{
res
.
clearCookie
(
'
token
'
)
res
.
clearCookie
(
'
token
'
)
res
.
send
(
'
Logout Successful
'
)
res
.
send
(
'
로그아웃 되었습니다
'
)
}
}
export
default
{
login
,
logout
}
export
default
{
login
,
logout
}
...
...
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