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
7498fb19
Commit
7498fb19
authored
Jan 11, 2021
by
박상호
🎼
Browse files
123
parent
8a73dfb2
Changes
2
Hide whitespace changes
Inline
Side-by-side
client/src/Auth.js
View file @
7498fb19
...
...
@@ -7,4 +7,13 @@ export function signIn({id,password}){
const
user
=
users
.
find
(
user
=>
user
.
id
===
id
&&
user
.
password
===
password
);
if
(
user
===
undefined
)
throw
new
Error
();
return
user
;
}
export
function
isAuthenticated
(){
const
userId
=
localStorage
.
getItem
(
"
loginStatus
"
)
if
(
userId
)
{
return
userId
}
else
{
return
false
}
}
\ No newline at end of file
client/src/Pages/Mypage.js
View file @
7498fb19
import
React
from
'
react
'
import
React
,
{
useEffect
,
useState
}
from
'
react
'
import
{
Card
,
Image
,
Container
,
Row
,
Col
,
Table
,
Accordion
}
from
'
react-bootstrap
'
import
{
Link
}
from
'
react-router-dom
'
;
import
person
from
'
../person.svg
'
;
import
mypagetiger
from
'
../mypagetiger.svg
'
;
import
catchErrors
from
'
../utils/catchErrors
'
;
import
{
isAuthenticated
}
from
'
../utils/auth
'
const
INIT_PROFILE
=
{
name
:
""
,
tel
:
""
}
function
Mypage
()
{
const
[
profile
,
setProfile
]
=
useState
(
INIT_PROFILE
)
const
[
error
,
setError
]
=
useState
(
""
)
const
user
=
isAuthenticated
()
async
function
getProfile
(
user
)
{
try
{
const
response
=
await
axios
.
get
(
`/api/users/profile/
${
user
}
`
)
setProfile
(
response
,
data
)
}
catch
(
error
)
{
catchErrors
(
error
,
setError
)
}
}
useEffect
(()
=>
{
getProfile
(
user
)
},
[
user
])
return
(
<
Container
className
=
"
px-3
"
>
<
h3
className
=
"
my-4 mx-3 font-weight-bold
"
>
My
Page
<
/h3
>
...
...
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