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
7b6cd315
Commit
7b6cd315
authored
Jul 18, 2021
by
KangMin An
Browse files
Create & Update : 메일 발송 추가
parent
3c19afc1
Changes
10
Show whitespace changes
Inline
Side-by-side
server/package.json
View file @
7b6cd315
...
...
@@ -30,6 +30,7 @@
"mysql2"
:
"^2.2.5"
,
"node-fetch"
:
"^2.6.1"
,
"node-schedule"
:
"^2.0.0"
,
"nodemailer"
:
"^6.6.2"
,
"pg"
:
"^8.6.0"
,
"pg-hstore"
:
"^2.3.4"
,
"pug"
:
"^3.0.0"
,
...
...
server/src/app.js
View file @
7b6cd315
...
...
@@ -14,6 +14,7 @@ import locCodeRouter from "./routers/locCodeRouter";
const
app
=
express
();
// Page Views for Development test.
app
.
set
(
"
view engine
"
,
"
pug
"
);
app
.
set
(
"
views
"
,
path
.
join
(
__dirname
,
"
views
"
));
...
...
server/src/controllers/dataController.js
View file @
7b6cd315
...
...
@@ -79,7 +79,7 @@ export const getDataInput = (req, res) => {
};
// 사용자의 데이터 가져오기 및 예측 값 전송
export
const
getUserData
=
(
req
,
res
)
=>
{
export
const
getUser
Weather
Data
=
(
req
,
res
)
=>
{
const
{
params
:
{
id
},
}
=
req
;
...
...
server/src/controllers/userController.js
0 → 100644
View file @
7b6cd315
import
dotenv
from
"
dotenv
"
;
import
nodemailer
from
"
nodemailer
"
;
import
{
serverMSG
,
statusCode
}
from
"
../serverinfo
"
;
dotenv
.
config
();
// Page for Development Test.
export
const
getSignup
=
(
req
,
res
)
=>
{
res
.
render
(
"
signup
"
,
{
pagename
:
"
Sign Up
"
});
};
// Page for Development Test.
export
const
getLogin
=
(
req
,
res
)
=>
{
res
.
render
(
"
login
"
,
{
pagename
:
"
Log In
"
});
};
// Function for Signup Proccess.
export
const
postSignup
=
async
(
req
,
res
)
=>
{
const
{
body
:
{
email
,
locCode
},
}
=
req
;
const
transporter
=
nodemailer
.
createTransport
({
service
:
process
.
env
.
NODEMAILER_SERVICE
,
auth
:
{
type
:
"
OAuth2
"
,
user
:
process
.
env
.
NODEMAILER_USER
,
clientId
:
process
.
env
.
NODEMAILER_GAMIL_CLIENT_ID
,
clientSecret
:
process
.
env
.
NODEMAILER_GMAIL_CLIENT_PASSWORD
,
refreshToken
:
process
.
env
.
NODEMAILER_GMAIL_REFRESH_TOKEN
,
},
tls
:
{
rejectUnauthorized
:
false
,
},
});
const
mailOptions
=
{
from
:
`EUE Auth Supply <
${
process
.
env
.
NODEMAILER_USER
}
>`
,
to
:
email
,
subject
:
"
EUE 사용자 계정 확인용 메일.
"
,
text
:
`You enter locCode :
${
locCode
}
.`
,
};
try
{
const
mailResult
=
await
transporter
.
sendMail
(
mailOptions
);
console
.
log
(
`Mail sent - ID :
${
mailResult
.
messageId
}
`
);
res
.
status
(
statusCode
.
ok
)
.
json
({
msg
:
serverMSG
.
server_ok
,
content
:
mailResult
.
response
});
}
catch
(
err
)
{
console
.
log
(
"
Mail Sending Failuer.
"
);
console
.
log
(
err
);
res
.
status
(
statusCode
.
err
)
.
json
({
msg
:
serverMSG
.
server_err
,
content
:
err
});
}
};
export
const
postLogin
=
(
req
,
res
)
=>
{};
server/src/routers/dataRouter.js
View file @
7b6cd315
import
express
from
"
express
"
;
import
routes
from
"
../routes
"
;
import
{
getDataInput
,
getUserData
}
from
"
../controllers/dataController
"
;
import
{
getDataInput
,
getUserWeatherData
,
}
from
"
../controllers/dataController
"
;
import
{
onlyPrivate
}
from
"
../middlewares
"
;
const
dataRouter
=
express
.
Router
();
dataRouter
.
get
(
routes
.
dataInput
,
getDataInput
);
dataRouter
.
get
(
routes
.
dataUser
,
onlyPrivate
,
getUserData
);
dataRouter
.
get
(
routes
.
dataUser
,
onlyPrivate
,
getUser
Weather
Data
);
export
default
dataRouter
;
server/src/routers/globalRouter.js
View file @
7b6cd315
import
express
from
"
express
"
;
import
routes
from
"
../routes
"
;
import
{
getHome
}
from
"
../controllers/globalController
"
;
import
{
getLogin
,
getSignup
,
postLogin
,
postSignup
,
}
from
"
../controllers/userController
"
;
const
globalRouter
=
express
.
Router
();
globalRouter
.
get
(
routes
.
home
,
getHome
);
// Authentication
globalRouter
.
get
(
routes
.
signup
,
getSignup
);
// For development test.
globalRouter
.
get
(
routes
.
login
,
getLogin
);
// For development test.
globalRouter
.
post
(
routes
.
signup
,
postSignup
);
globalRouter
.
post
(
routes
.
login
,
postLogin
);
export
default
globalRouter
;
server/src/routes.js
View file @
7b6cd315
...
...
@@ -16,7 +16,7 @@ const SIGUNGU = "/si-gun-gu";
const
EUPMYEONDONG
=
"
/eup-myeon-dong
"
;
// # Auth
const
REGISTER
=
"
/register
"
;
const
SIGNUP
=
"
/signup
"
;
const
LOGIN
=
"
/login
"
;
const
EDIT_PROFILE
=
"
/edit-profile
"
;
...
...
@@ -33,7 +33,7 @@ const routes = {
doe
:
DOE
,
sigungu
:
SIGUNGU
,
eupmyeondong
:
EUPMYEONDONG
,
register
:
REGISTER
,
signup
:
SIGNUP
,
login
:
LOGIN
,
editProfile
:
EDIT_PROFILE
,
Detail
:
(
id
)
=>
{
...
...
server/src/views/home.pug
View file @
7b6cd315
...
...
@@ -5,4 +5,6 @@ block content
li
a(href=routes.data+routes.dataInput) 데이터 등록
li
a(href=routes.data+routes.dataOutput) 데이터 출력
\ No newline at end of file
a(href=routes.signup) 회원가입
li
a(href=routes.login) 로그인
\ No newline at end of file
server/src/views/login.pug
0 → 100644
View file @
7b6cd315
block content
.login-form_container
form(action=routes.login, method="post")
input(type="email", name="email", require=true, placeholder="E-mail")
input(type="submit", value="Submit")
\ No newline at end of file
server/src/views/signup.pug
0 → 100644
View file @
7b6cd315
block content
.signup-form_container
form(action = routes.signup, method = "post")
input(type="email", name="email", require=true, placeholder="E-mail")
input(type="number", name="locCode")
input(type="submit", value="Submit")
\ 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