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
quiz-competition
Commits
ed3a5413
Commit
ed3a5413
authored
Oct 28, 2020
by
baesangjune
Browse files
중간
parent
1c18d0e1
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/client/src/auth/Signin.jsx
View file @
ed3a5413
...
@@ -6,6 +6,7 @@ import { signin } from "./api-auth";
...
@@ -6,6 +6,7 @@ import { signin } from "./api-auth";
import
auth
from
"
./auth-helpers
"
;
import
auth
from
"
./auth-helpers
"
;
import
{
Redirect
}
from
"
react-router-dom
"
;
import
{
Redirect
}
from
"
react-router-dom
"
;
import
{
useAuth
}
from
"
./auth-context
"
;
import
{
useAuth
}
from
"
./auth-context
"
;
import
{
Link
}
from
"
react-router-dom
"
function
Signin
()
{
function
Signin
()
{
const
{
setAuthUser
}
=
useAuth
();
const
{
setAuthUser
}
=
useAuth
();
...
@@ -45,6 +46,7 @@ function Signin() {
...
@@ -45,6 +46,7 @@ function Signin() {
return
(
return
(
<
Container
className
=
"col-sm-6 col-md-5 col-lg-4 p-5"
>
<
Container
className
=
"col-sm-6 col-md-5 col-lg-4 p-5"
>
<
h1
className
=
"text-center mt-1 pb-3 font-italic text-danger"
>
Korea
<
br
/>
University
</
h1
>
<
Form
>
<
Form
>
<
Form
.
Group
controlId
=
"email"
>
<
Form
.
Group
controlId
=
"email"
>
<
Form
.
Label
>
Email
</
Form
.
Label
>
<
Form
.
Label
>
Email
</
Form
.
Label
>
...
@@ -62,16 +64,20 @@ function Signin() {
...
@@ -62,16 +64,20 @@ function Signin() {
<
Form
.
Label
>
Password
</
Form
.
Label
>
<
Form
.
Label
>
Password
</
Form
.
Label
>
<
Form
.
Control
<
Form
.
Control
type
=
"password"
type
=
"password"
placeholder
=
"Password"
placeholder
=
"
Enter
Password"
onChange
=
{
handleChange
(
"
password
"
)
}
onChange
=
{
handleChange
(
"
password
"
)
}
/>
/>
</
Form
.
Group
>
</
Form
.
Group
>
<
Button
variant
=
"
primary
"
type
=
"submit"
onClick
=
{
clickSubmit
}
>
<
Button
block
variant
=
"
danger
"
type
=
"submit"
onClick
=
{
clickSubmit
}
>
S
ubmit
S
ign in
</
Button
>
</
Button
>
<
Link
to
=
"/signup"
>
<
Button
block
className
=
"text-left"
variant
=
"default"
>
New Account
</
Button
>
</
Link
>
</
Form
>
</
Form
>
</
Container
>
</
Container
>
);
);
}
}
...
...
src/client/src/core/Home.jsx
View file @
ed3a5413
import
React
from
'
react
'
import
React
from
'
react
'
import
Signin
from
'
../auth/Signin
'
import
{
useAuth
}
from
"
../auth/auth-context
"
import
Warning
from
'
./Warning
'
function
Home
()
{
function
Home
()
{
const
{
authUser
}
=
useAuth
()
return
(
return
(
<
div
>
<
div
>
Home
{
authUser
?
<
Warning
/>:<
Signin
/>
}
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
</
div
>
</
div
>
)
)
}
}
export
default
Home
export
default
Home
src/client/src/core/Warning.jsx
0 → 100644
View file @
ed3a5413
import
React
,
{
useState
}
from
"
react
"
import
{
useAuth
}
from
"
../auth/auth-context
"
import
Form
from
"
react-bootstrap/Form
"
;
import
Container
from
"
react-bootstrap/Container
"
;
import
{
read
as
readUser
}
from
'
../user/api-user
'
;
import
{
read
as
readCourse
}
from
'
../course/api-course
'
;
import
{
useEffect
}
from
"
react
"
;
function
Warning
()
{
const
{
authUser
}
=
useAuth
()
useEffect
(()
=>
{
readUser
(
authUser
.
user
.
_id
,
{
t
:
authUser
.
token
}).
then
(
res
=>
{
setData
(
res
);
})
readCourse
(
"
5f7fc9071575948025e29ebb
"
,
{
t
:
authUser
.
token
}).
then
(
res
=>
{
console
.
log
(
res
);
setCourse
(
res
);
})
},
[])
const
[
data
,
setData
]
=
useState
({
name
:
""
,
})
const
[
course
,
setCourse
]
=
useState
({
name
:
""
,
description
:
""
,
code
:
""
,
})
return
(
<
div
>
<
Container
className
=
"col-sm-6 col-md-5 col-lg-4 p-5"
>
{
console
.
log
(
data
)
}
<
Form
.
Text
className
=
"text-muted"
>
<
h1
className
=
"text-center mt-1 pb-3 font-italic text-danger"
>
Korea University
</
h1
>
<
p
>
응시자 정보
</
p
>
<
p
>
이름 :
{
data
.
name
}
</
p
>
<
p
>
e-mail :
{
data
.
email
}
</
p
>
<
p
>
응시 과목 :
{
course
.
name
}
</
p
>
<
p
>
담당 교수 :
{
course
.
description
}
</
p
>
{
/* <p>시험문제 수 :</p>
<p>시험 시간 : </p>
<p>공지 사항 : </p> */
}
</
Form
.
Text
>
</
Container
>
</
div
>
)
}
export
default
Warning
\ No newline at end of file
src/client/src/course/api-course.js
View file @
ed3a5413
...
@@ -14,6 +14,22 @@ const list = async (signal) => {
...
@@ -14,6 +14,22 @@ const list = async (signal) => {
}
}
}
}
const
read
=
async
(
courseId
,
credentials
)
=>
{
try
{
const
response
=
await
fetch
(
'
/api/courses/
'
+
courseId
,
{
method
:
'
GET
'
,
headers
:
{
'
Accept
'
:
'
application/json
'
,
'
Content-Type
'
:
'
application/json
'
,
'
Authorization
'
:
'
Bearer
'
+
credentials
.
t
,
},
})
return
await
response
.
json
()
}
catch
(
error
)
{
console
.
log
(
error
)
}
}
export
{
export
{
list
,
list
,
read
}
}
src/client/src/user/Signup.jsx
View file @
ed3a5413
...
@@ -47,6 +47,9 @@ function Signup() {
...
@@ -47,6 +47,9 @@ function Signup() {
return
(
return
(
<
Container
fluid
>
<
Container
fluid
>
<
div
>
<
h1
className
=
"mt-3 text-center mt-1 pb-3 font-italic text-danger"
>
Korea
<
br
/>
University
</
h1
>
</
div
>
<
Row
className
=
"justify-content-center"
>
<
Row
className
=
"justify-content-center"
>
<
Col
className
=
"col-sm-6 col-md-7"
>
<
Col
className
=
"col-sm-6 col-md-7"
>
<
Form
>
<
Form
>
...
...
src/client/src/user/api-user.js
View file @
ed3a5413
...
@@ -14,6 +14,23 @@ const create = async (user) => {
...
@@ -14,6 +14,23 @@ const create = async (user) => {
}
}
}
}
const
read
=
async
(
userId
,
credentials
)
=>
{
try
{
const
response
=
await
fetch
(
'
/api/users/
'
+
userId
,
{
method
:
'
GET
'
,
headers
:
{
'
Accept
'
:
'
application/json
'
,
'
Content-Type
'
:
'
application/json
'
,
'
Authorization
'
:
'
Bearer
'
+
credentials
.
t
,
},
})
return
await
response
.
json
()
}
catch
(
error
)
{
console
.
log
(
error
)
}
}
export
{
export
{
create
,
create
,
read
,
}
}
\ 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