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
eue
Commits
fe677cec
Commit
fe677cec
authored
Aug 02, 2021
by
KangMin An
Browse files
Merge branch 'who' into premaster
parents
3096fb08
d4672581
Changes
13
Hide whitespace changes
Inline
Side-by-side
client/src/App.js
View file @
fe677cec
...
@@ -12,7 +12,7 @@ import GetLocFirst from './pages/GetLocFirst';
...
@@ -12,7 +12,7 @@ import GetLocFirst from './pages/GetLocFirst';
function
App
()
{
function
App
()
{
const
isLs
=
localStorage
.
getItem
(
'
login
'
)
const
isLs
=
localStorage
.
getItem
(
'
login
'
)
function
loginDefault
()
{
function
loginDefault
()
{
...
@@ -29,7 +29,7 @@ function App() {
...
@@ -29,7 +29,7 @@ function App() {
<
Route
path
=
'
/signup
'
component
=
{
SignupPage
}
/
>
<
Route
path
=
'
/signup
'
component
=
{
SignupPage
}
/
>
<
Route
path
=
'
/login
'
component
=
{
LoginPage
}
/
>
<
Route
path
=
'
/login
'
component
=
{
LoginPage
}
/
>
<
Route
path
=
'
/first-local-code
'
component
=
{
GetLocFirst
}
/
>
<
Route
path
=
'
/first-local-code
'
component
=
{
GetLocFirst
}
/
>
<
PrivateRoute
path
=
'
/edit
'
>
<
PrivateRoute
path
=
'
/edit
'
>
<
EditPage
/>
<
EditPage
/>
<
/PrivateRoute
>
<
/PrivateRoute
>
...
...
client/src/Utils/Auth.js
View file @
fe677cec
import
axios
from
"
axios
"
;
import
axios
from
"
axios
"
;
import
Swal
from
"
sweetalert2
"
;
import
Swal
from
"
sweetalert2
"
;
import
{
routesClient
}
from
'
./../routesClient
'
;
export
function
isOauth
(
value
)
{
const
TFoauth
=
value
;
return
TFoauth
;
}
export
function
isLogined
()
{
export
function
isLogined
()
{
const
whetherlogin
=
localStorage
.
getItem
(
"
login
"
);
const
whetherlogin
=
localStorage
.
getItem
(
"
login
"
);
...
@@ -16,7 +13,7 @@ export function isLogined() {
...
@@ -16,7 +13,7 @@ export function isLogined() {
}
}
export
async
function
localLogout
()
{
export
async
function
localLogout
()
{
await
axios
.
get
(
"
/api/
logout
"
).
then
(
function
()
{
await
axios
.
get
(
routesClient
.
logout
).
then
(
function
()
{
localStorage
.
clear
();
localStorage
.
clear
();
Swal
.
fire
({
Swal
.
fire
({
title
:
"
로그아웃 성공!
"
,
title
:
"
로그아웃 성공!
"
,
...
...
client/src/Utils/CheckDB.js
View file @
fe677cec
import
axios
from
'
axios
'
;
import
axios
from
'
axios
'
;
import
{
Swal
}
from
'
sweetalert2
'
;
import
{
Swal
}
from
'
sweetalert2
'
;
import
{
routesClient
}
from
'
./../routesClient
'
;
export
async
function
callUserInfo
()
{
export
async
function
callUserInfo
()
{
const
res
=
await
axios
.
get
(
"
/api/
user
-
info
"
)
const
res
=
await
axios
.
get
(
routesClient
.
userinfo
)
return
res
.
data
.
contents
.
user_info
return
res
.
data
.
contents
.
user_info
}
}
...
...
client/src/Utils/Oauth.js
View file @
fe677cec
import
axios
from
'
axios
'
;
import
axios
from
'
axios
'
;
import
Swal
from
'
sweetalert2
'
import
Swal
from
'
sweetalert2
'
import
'
../App.css
'
import
'
../App.css
'
import
{
routesClient
}
from
'
./../routesClient
'
;
// export const KAKAO_AUTH_URL = `https://kauth.kakao.com/oauth/authorize?client_id=${CLIENT_ID}&redirect_uri=${REDIRECT_URI}&response_type=code`;
// export const KAKAO_AUTH_URL = `https://kauth.kakao.com/oauth/authorize?client_id=${CLIENT_ID}&redirect_uri=${REDIRECT_URI}&response_type=code`;
...
@@ -28,12 +29,13 @@ export function LoginWithKakao() {
...
@@ -28,12 +29,13 @@ export function LoginWithKakao() {
console
.
log
(
response
);
console
.
log
(
response
);
console
.
log
(
response
.
kakao_account
.
profile
);
console
.
log
(
response
.
kakao_account
.
profile
);
const
nickValue
=
Object
.
values
(
response
.
kakao_account
.
profile
)
const
nickValue
=
response
.
kakao_account
.
profile
[
'
nickname
'
]
const
emailValue
=
response
.
kakao_account
.
email
await
axios
.
post
(
'
/api/edit-profile
'
,
{
nick_name
:
nickValue
})
await
axios
.
post
(
routesClient
.
signup
,
{
email
:
emailValue
,
nick_name
:
nickValue
,
isOauth
:
true
})
.
then
((
res
)
=>
console
.
log
(
'
kakao
'
,
res
))
.
then
((
res
)
=>
console
.
log
(
'
kakao
'
,
res
))
localStorage
.
setItem
(
'
login
'
,
true
)
//
localStorage.setItem('login', true)
Swal
.
fire
({
Swal
.
fire
({
title
:
'
로그인 성공!
'
,
title
:
'
로그인 성공!
'
,
text
:
'
🙌 환영합니다 🙌
'
,
text
:
'
🙌 환영합니다 🙌
'
,
...
...
client/src/components/LocCodeChange.js
View file @
fe677cec
...
@@ -4,6 +4,7 @@ import { Form, Button, Row, Col, Card } from 'react-bootstrap';
...
@@ -4,6 +4,7 @@ import { Form, Button, Row, Col, Card } from 'react-bootstrap';
import
axios
from
'
axios
'
;
import
axios
from
'
axios
'
;
import
Swal
from
'
sweetalert2
'
import
Swal
from
'
sweetalert2
'
import
{
callUserInfo
}
from
'
../utils/CheckDB
'
;
import
{
callUserInfo
}
from
'
../utils/CheckDB
'
;
import
{
routesClient
}
from
'
../routesClient
'
;
function
LocCodeChange
()
{
function
LocCodeChange
()
{
...
@@ -51,7 +52,7 @@ function LocCodeChange() {
...
@@ -51,7 +52,7 @@ function LocCodeChange() {
// Local code 받아오기
// Local code 받아오기
useEffect
(()
=>
{
useEffect
(()
=>
{
async
function
getLocCode
()
{
async
function
getLocCode
()
{
const
res
=
await
axios
.
get
(
"
/api/data/loccode
"
)
const
res
=
await
axios
.
get
(
routesClient
.
localdata
)
const
local_codes
=
res
.
data
.
contents
.
loc_code
const
local_codes
=
res
.
data
.
contents
.
loc_code
setDoes
(
local_codes
.
DOE
)
setDoes
(
local_codes
.
DOE
)
...
@@ -85,7 +86,7 @@ function LocCodeChange() {
...
@@ -85,7 +86,7 @@ function LocCodeChange() {
const
saveCodeEmd
=
emdSelect
.
value
const
saveCodeEmd
=
emdSelect
.
value
await
axios
.
post
(
'
/api/edit-profile
'
,
{
loc_code
:
saveCodeEmd
})
// loccal code 수정
await
axios
.
post
(
routesClient
.
edit
,
{
loc_code
:
saveCodeEmd
})
// loccal code 수정
callUserInfo
().
then
((
res
)
=>
{
callUserInfo
().
then
((
res
)
=>
{
console
.
log
(
'
loc_code
'
,
res
[
0
].
loc_code
)
console
.
log
(
'
loc_code
'
,
res
[
0
].
loc_code
)
...
...
client/src/components/LoginComp.js
View file @
fe677cec
...
@@ -3,6 +3,7 @@ import '../App.css'
...
@@ -3,6 +3,7 @@ import '../App.css'
import
{
Form
,
Button
,
Row
,
Col
,
Card
,
Alert
,
FloatingLabel
}
from
'
react-bootstrap
'
;
import
{
Form
,
Button
,
Row
,
Col
,
Card
,
Alert
,
FloatingLabel
}
from
'
react-bootstrap
'
;
import
{
LoginWithKakao
}
from
'
../utils/Oauth
'
;
import
{
LoginWithKakao
}
from
'
../utils/Oauth
'
;
import
axios
from
'
axios
'
;
import
axios
from
'
axios
'
;
import
{
routesClient
}
from
'
../routesClient
'
;
function
LoginComp
()
{
function
LoginComp
()
{
...
@@ -35,15 +36,12 @@ function LoginComp() {
...
@@ -35,15 +36,12 @@ function LoginComp() {
function
addressUrl
()
{
function
addressUrl
()
{
const
afterAt
=
emailAddress
.
split
(
'
@
'
)[
1
]
const
afterAt
=
emailAddress
.
split
(
'
@
'
)[
1
]
if
(
afterAt
==
(
'
naver.com
'
||
'
gmail.com
'
||
'
daum.net
'
)
)
{
if
(
afterAt
)
{
const
newLink
=
'
https://www.
'
+
afterAt
;
const
newLink
=
'
https://www.
'
+
afterAt
;
window
.
open
(
newLink
);
window
.
location
.
replace
(
newLink
);
}
}
if
(
afterAt
==
'
korea.ac.kr
'
)
{
else
if
(
afterAt
==
'
korea.ac.kr
'
)
{
window
.
open
(
'
https://www.gmail.com
'
);
window
.
location
.
replace
(
'
https://www.gmail.com
'
);
}
else
{
window
.
open
();
}
}
}
}
...
@@ -53,7 +51,7 @@ function LoginComp() {
...
@@ -53,7 +51,7 @@ function LoginComp() {
async
function
handleSubmit
(
event
)
{
async
function
handleSubmit
(
event
)
{
event
.
preventDefault
();
event
.
preventDefault
();
const
res
=
await
axios
.
post
(
"
/api/
login
"
,
{
email
:
emailAddress
})
const
res
=
await
axios
.
post
(
routesClient
.
login
,
{
email
:
emailAddress
,
isOauth
:
false
})
console
.
log
(
'
mail_sending :
'
,
res
.
data
.
contents
.
mail_sending
)
console
.
log
(
'
mail_sending :
'
,
res
.
data
.
contents
.
mail_sending
)
setMailSend
(
res
.
data
.
contents
.
mail_sending
)
setMailSend
(
res
.
data
.
contents
.
mail_sending
)
setAlertShow
(
true
)
setAlertShow
(
true
)
...
@@ -96,7 +94,7 @@ function LoginComp() {
...
@@ -96,7 +94,7 @@ function LoginComp() {
<
Form
style
=
{
inboxstyled
}
onSubmit
=
{
handleSubmit
}
>
<
Form
style
=
{
inboxstyled
}
onSubmit
=
{
handleSubmit
}
>
<
FloatingLabel
label
=
"
Email
"
>
<
FloatingLabel
label
=
"
Email
"
>
<
Form
.
Control
type
=
"
email
"
placeholder
=
"
Email
"
onChange
=
{
handleChange
}
required
/>
<
Form
.
Control
type
=
"
email
"
placeholder
=
"
Email
"
onChange
=
{
handleChange
}
required
/>
<
/FloatingLabel
>
<
/FloatingLabel
>
<
Button
variant
=
'
light
'
className
=
'
mt-3
'
id
=
'
formbtn
'
type
=
'
submit
'
>
<
Button
variant
=
'
light
'
className
=
'
mt-3
'
id
=
'
formbtn
'
type
=
'
submit
'
>
LOGIN
LOGIN
...
...
client/src/components/NicknameChange.js
View file @
fe677cec
...
@@ -2,6 +2,7 @@ import axios from 'axios';
...
@@ -2,6 +2,7 @@ import axios from 'axios';
import
React
,
{
useState
}
from
'
react
'
import
React
,
{
useState
}
from
'
react
'
import
{
Row
,
Card
,
Form
,
Button
,
FloatingLabel
}
from
'
react-bootstrap
'
;
import
{
Row
,
Card
,
Form
,
Button
,
FloatingLabel
}
from
'
react-bootstrap
'
;
import
Swal
from
'
sweetalert2
'
;
import
Swal
from
'
sweetalert2
'
;
import
{
routesClient
}
from
'
./../routesClient
'
;
function
NicknameChange
()
{
function
NicknameChange
()
{
...
@@ -36,7 +37,7 @@ function NicknameChange() {
...
@@ -36,7 +37,7 @@ function NicknameChange() {
async
function
handleSubmit
(
event
)
{
async
function
handleSubmit
(
event
)
{
event
.
preventDefault
();
event
.
preventDefault
();
if
(
inputname
!==
''
)
{
if
(
inputname
!==
''
)
{
await
axios
.
post
(
'
/api/edit-profile
'
,
{
nick_name
:
inputname
})
await
axios
.
post
(
routesClient
.
edit
,
{
nick_name
:
inputname
})
.
then
(
function
(
response
)
{
.
then
(
function
(
response
)
{
console
.
log
(
response
.
data
.
msg
);
console
.
log
(
response
.
data
.
msg
);
if
(
response
.
data
.
msg
===
'
OK!
'
)
{
if
(
response
.
data
.
msg
===
'
OK!
'
)
{
...
...
client/src/components/SignupComp.js
View file @
fe677cec
...
@@ -3,6 +3,7 @@ import '../App.css'
...
@@ -3,6 +3,7 @@ import '../App.css'
import
{
Form
,
Button
,
Row
,
Col
,
Card
,
Alert
,
FloatingLabel
}
from
'
react-bootstrap
'
;
import
{
Form
,
Button
,
Row
,
Col
,
Card
,
Alert
,
FloatingLabel
}
from
'
react-bootstrap
'
;
import
{
LoginWithKakao
}
from
'
../utils/Oauth
'
;
import
{
LoginWithKakao
}
from
'
../utils/Oauth
'
;
import
axios
from
'
axios
'
;
import
axios
from
'
axios
'
;
import
{
routesClient
}
from
'
./../routesClient
'
;
function
SignupComp
()
{
function
SignupComp
()
{
...
@@ -30,7 +31,8 @@ function SignupComp() {
...
@@ -30,7 +31,8 @@ function SignupComp() {
const
initValues
=
{
const
initValues
=
{
nick_name
:
''
,
nick_name
:
''
,
email
:
''
email
:
''
,
isOauth
:
false
}
}
const
[
formValues
,
setFormValues
]
=
useState
(
initValues
)
const
[
formValues
,
setFormValues
]
=
useState
(
initValues
)
...
@@ -45,21 +47,12 @@ function SignupComp() {
...
@@ -45,21 +47,12 @@ function SignupComp() {
async
function
handleSubmit
(
event
)
{
async
function
handleSubmit
(
event
)
{
event
.
preventDefault
();
event
.
preventDefault
();
const
res
=
await
axios
.
post
(
"
/api/
signup
"
,
formValues
)
const
res
=
await
axios
.
post
(
routesClient
.
signup
,
formValues
)
console
.
log
(
'
existing_user :
'
,
res
.
data
.
contents
.
existing_user
)
console
.
log
(
'
existing_user :
'
,
res
.
data
.
contents
.
existing_user
)
setUserExist
(
res
.
data
.
contents
.
existing_user
)
setUserExist
(
res
.
data
.
contents
.
existing_user
)
setAlertShow
(
true
)
setAlertShow
(
true
)
}
}
useEffect
(()
=>
{
async
function
test
()
{
const
res
=
await
axios
.
get
(
'
/api/signup
'
)
console
.
log
(
res
.
contents
)
}
test
()
},
[])
return
(
return
(
<
Row
className
=
'
text-center w-100 my-2
'
>
<
Row
className
=
'
text-center w-100 my-2
'
>
...
...
client/src/components/UsingAircon.js
View file @
fe677cec
import
axios
from
"
axios
"
;
import
axios
from
"
axios
"
;
import
React
,
{
useEffect
,
useState
}
from
"
react
"
;
import
React
,
{
useEffect
,
useState
}
from
"
react
"
;
import
{
Form
}
from
"
react-bootstrap
"
;
import
{
Form
}
from
"
react-bootstrap
"
;
import
{
callUserInfo
,
checkCookies
}
from
"
../utils/CheckDB
"
;
import
{
callUserInfo
}
from
"
../utils/CheckDB
"
;
import
{
isLogined
}
from
"
./../utils/Auth
"
;
import
{
isLogined
}
from
"
./../utils/Auth
"
;
import
{
routesClient
}
from
'
./../routesClient
'
;
function
UsingAircon
()
{
function
UsingAircon
()
{
const
[
airUsing
,
setAirUsing
]
=
useState
(
false
);
const
[
airUsing
,
setAirUsing
]
=
useState
(
''
);
// useEffect(() => {
console
.
log
(
"
change airUsing
"
,
airUsing
);
// callUserInfo().then((res) => {
// if (isLogined()) {
// setAirUsing(res.using_aircon)
// }
// else {
// console.log(res)
// }
// })
// }, [checkCookies()])
function
airChange
()
{
async
function
airChange
()
{
setAirUsing
(
!
airUsing
);
setAirUsing
(
!
airUsing
);
async
function
Useair
()
{
await
axios
.
get
(
routesClient
.
usingAircon
,
{
using_aircon
:
!
airUsing
})
const
res
=
await
axios
.
get
(
"
/api/toggle-aircon
"
);
console
.
log
(
res
);
}
Useair
();
}
}
console
.
log
(
"
airUsing
"
,
airUsing
);
useEffect
(()
=>
{
callUserInfo
().
then
((
res
)
=>
{
setAirUsing
(
res
[
0
][
'
using_aircon
'
])
})
},
[])
return
(
return
(
<>
<>
...
...
client/src/pages/GetLocFirst.js
View file @
fe677cec
...
@@ -8,6 +8,7 @@ import ChartLine from '../components/ChartLine';
...
@@ -8,6 +8,7 @@ import ChartLine from '../components/ChartLine';
import
ChartDoughnut
from
'
../components/ChartDoughnut
'
;
import
ChartDoughnut
from
'
../components/ChartDoughnut
'
;
import
Donation
from
'
../components/Donation
'
;
import
Donation
from
'
../components/Donation
'
;
import
LocCodeChange
from
'
../components/LocCodeChange
'
;
import
LocCodeChange
from
'
../components/LocCodeChange
'
;
import
{
callUserInfo
}
from
'
../utils/CheckDB
'
;
function
GetLocFirst
()
{
function
GetLocFirst
()
{
const
constyled
=
{
const
constyled
=
{
...
@@ -31,13 +32,28 @@ function GetLocFirst() {
...
@@ -31,13 +32,28 @@ function GetLocFirst() {
padding
:
'
0
'
padding
:
'
0
'
}
}
const
[
existLoc
,
setExistLoc
]
=
useState
(
''
)
const
[
show
,
setShow
]
=
useState
(
false
)
useEffect
(()
=>
{
useEffect
(()
=>
{
setTimeout
(
function
()
{
callUserInfo
().
then
((
res
)
=>
{
set
Show
(
true
)
set
ExistLoc
(
res
[
0
][
'
loc_code
'
]
)
}
,
1500
)
})
},
[])
},
[])
const
[
show
,
setShow
]
=
useState
(
false
)
useEffect
(()
=>
{
if
(
existLoc
===
''
)
{
setTimeout
(
function
()
{
setShow
(
true
)
},
1500
)
}
else
{
setShow
(
false
)
window
.
location
.
replace
(
'
/
'
)
}
},
[
existLoc
])
return
(
return
(
<
Container
className
=
'
m-auto d-flex position-relative
'
<
Container
className
=
'
m-auto d-flex position-relative
'
...
...
client/src/routes.js
deleted
100644 → 0
View file @
3096fb08
export
const
routes
=
{
home
:
'
/
'
,
signup
:
'
/signup
'
,
login
:
'
login
'
,
edit
:
'
/edit
'
,
}
// post, put { body }
// email :
// nick_name :
// using_aircon :
// created_at :
// loc_code
client/src/routesClient.js
0 → 100644
View file @
fe677cec
export
const
routesClient
=
{
home
:
'
/api
'
,
signup
:
'
/api/signup
'
,
login
:
'
/api/login
'
,
edit
:
'
/api/edit-profile
'
,
localdata
:
'
/api/data/loccode
'
,
usingAircon
:
'
/api/toggle-aircon
'
,
logout
:
'
/api/logout
'
,
userinfo
:
'
/api/user-info
'
}
// post, put { body }
// email :
// nick_name :
// using_aircon :
// created_at :
// loc_code
server/src/controllers/userController.js
View file @
fe677cec
...
@@ -25,13 +25,10 @@ const postMail = async (email, token) => {
...
@@ -25,13 +25,10 @@ const postMail = async (email, token) => {
from
:
`EUE Auth Supply <
${
envs
.
api
.
nodemailer
.
user
}
>`
,
from
:
`EUE Auth Supply <
${
envs
.
api
.
nodemailer
.
user
}
>`
,
to
:
email
,
to
:
email
,
subject
:
"
EUE 사용자 계정 확인용 메일.
"
,
subject
:
"
EUE 사용자 계정 확인용 메일.
"
,
html
:
`<a href="
${
envs
.
server
.
protocol
}
://
${
envs
.
server
.
host
}
:
${
html
:
`<a href="
${
envs
.
server
.
protocol
}
://
${
envs
.
server
.
host
}
:
${
envs
.
server
.
port
envs
.
server
.
port
}${
routes
.
base
+
routes
.
confirm
}
?token=
${
token
}
">
${
envs
.
server
.
protocol
}${
routes
.
base
+
routes
.
confirm
}
?token=
${
token
}
">
${
}
://
${
envs
.
server
.
host
}
:
${
envs
.
server
.
port
}${
routes
.
base
+
routes
.
confirm
envs
.
server
.
protocol
}
?token=
${
token
}
</a>`
,
}
://
${
envs
.
server
.
host
}
:
${
envs
.
server
.
port
}${
routes
.
base
+
routes
.
confirm
}
?token=
${
token
}
</a>`
,
};
};
try
{
try
{
...
@@ -161,6 +158,7 @@ export const getConfirm = async (req, res) => {
...
@@ -161,6 +158,7 @@ export const getConfirm = async (req, res) => {
`
${
envs
.
client
.
protocol
}
://
${
envs
.
client
.
host
}
:
${
envs
.
client
.
port
}
/first-local-code`
`
${
envs
.
client
.
protocol
}
://
${
envs
.
client
.
host
}
:
${
envs
.
client
.
port
}
/first-local-code`
);
);
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
'
22
'
,
err
);
res
.
json
({
msg
:
resForm
.
msg
.
err
,
contents
:
{
error
:
err
}
});
res
.
json
({
msg
:
resForm
.
msg
.
err
,
contents
:
{
error
:
err
}
});
}
}
};
};
...
...
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