Toggle navigation
Toggle navigation
This project
Loading...
Sign in
오인제
/
Tunnel
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
정의왕
2021-12-08 22:20:24 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3dd290fd17ad82da0c66b3c99a02efd4bb8f4929
3dd290fd
1 parent
e4f96efc
Complete Login/Register(without auth)
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
3 deletions
turnel_FE/src/App.js
turnel_FE/src/component/views/LoginPage/LoginPage.js
turnel_FE/src/component/views/RegisterPage/RegisterPage.js
turnel_FE/src/App.js
View file @
3dd290f
...
...
@@ -6,9 +6,11 @@ import "./static/fonts/font.css";
import
LandingPage
from
"./component/views/LandingPage/LandingPage"
;
function
App
()
{
let
isAuthorized
=
sessionStorage
.
getItem
(
"isAuthorized"
);
//
return
(
<
Router
>
<
div
>
{
!
isAuthorized
?
<
Redirect
to
=
"/login"
/>
:
<
Redirect
to
=
"/"
/>
}
<
Routes
>
<
Route
exact
path
=
"/"
element
=
{
<
LandingPage
/>
}
/
>
<
Route
exact
path
=
"/login"
element
=
{
<
LoginPage
/>
}
/
>
...
...
turnel_FE/src/component/views/LoginPage/LoginPage.js
View file @
3dd290f
import
React
,
{
useState
}
from
"react"
;
import
"../style/LoginPage.scss"
;
import
Axios
from
'axios'
import
{
Icon
,
Input
}
from
"semantic-ui-react"
import
{
useNavigate
}
from
"react-router-dom"
;
...
...
@@ -19,8 +20,24 @@ function LoginPage(props) {
event
.
preventDefault
();
console
.
log
(
"ID"
,
Id
);
console
.
log
(
"Password"
,
Password
);
};
Axios
.
post
(
'/api/login'
,{
Id
,
Password
,
})
.
then
((
res
)
=>
{
if
(
res
.
status
===
200
){
alert
(
"성공적으로 로그인하였습니다."
)
navigate
(
'/main'
)
}
}).
catch
((
error
)
=>
{
if
(
error
.
response
.
data
===
'idError'
){
alert
(
"존재하지 않는 아이디입니다."
)
}
else
if
(
error
.
response
.
data
===
'pwError'
){
alert
(
"잘못된 비밀번호입니다."
)
}
})
};
const
goToRegister
=
()
=>
{
navigate
(
'/register'
);
}
...
...
turnel_FE/src/component/views/RegisterPage/RegisterPage.js
View file @
3dd290f
...
...
@@ -45,9 +45,9 @@ function RegisterPage(props) {
}
}).
catch
((
error
)
=>
{
console
.
log
(
error
.
response
)
alert
(
"중복된 아이디입니다."
)
})
}
},[
Id
,
Password
,
Personality
,
PasswordCheck
])
return
(
<
div
id
=
"Register"
>
...
...
Please
register
or
login
to post a comment