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
a675d529
Commit
a675d529
authored
Jul 21, 2021
by
KangMin An
Browse files
Update : Test Pages. Send Mail with Token.
parent
3bddb53f
Changes
5
Hide whitespace changes
Inline
Side-by-side
server/src/controllers/locCodeController.js
deleted
100644 → 0
View file @
3bddb53f
import
db
from
"
../db/index
"
;
import
{
serverMSG
,
statusCode
}
from
"
../serverinfo
"
;
// Do Code에 대한 GET 요청 처리
export
const
getDoe
=
async
(
req
,
res
)
=>
{
const
result
=
await
db
.
Doe
.
findAll
({
logging
:
false
});
if
(
result
)
{
res
.
status
(
statusCode
.
ok
).
json
({
DO
:
result
});
}
else
{
res
.
status
(
statusCode
.
err
).
send
(
serverMSG
.
server_err
);
}
};
// SGG Code에 대한 GET 요청 처리
export
const
getSGG
=
async
(
req
,
res
)
=>
{
const
{
params
:
{
id
},
}
=
req
;
const
result
=
await
db
.
Sgg
.
findAll
({
where
:
{
code_doe
:
Number
(
id
)
},
logging
:
false
,
});
if
(
result
)
{
res
.
status
(
statusCode
.
ok
).
json
({
DO
:
Number
(
id
),
SGG
:
result
});
}
else
{
console
.
log
(
result
);
res
.
status
(
statusCode
.
err
).
send
(
serverMSG
.
server_err
);
}
};
// EMD Code에 대한 GET 요청 처리
export
const
getEMD
=
async
(
req
,
res
)
=>
{
const
{
params
:
{
id
},
}
=
req
;
const
result
=
await
db
.
Emd
.
findAll
({
where
:
{
code_sgg
:
Number
(
id
)
},
logging
:
false
,
});
if
(
result
)
{
res
.
status
(
statusCode
.
ok
).
json
({
SGG
:
Number
(
id
),
EMD
:
result
});
}
else
{
console
.
log
(
result
);
res
.
status
(
statusCode
.
err
).
send
(
serverMSG
.
server_err
);
}
};
server/src/controllers/userController.js
View file @
a675d529
...
...
@@ -26,9 +26,11 @@ const postMail = async (email, token) => {
from
:
`EUE Auth Supply <
${
process
.
env
.
NODEMAILER_USER
}
>`
,
to
:
email
,
subject
:
"
EUE 사용자 계정 확인용 메일.
"
,
html
:
`<a href="
${
process
.
env
.
HOST
}
:
${
process
.
env
.
PORT
}${
routes
.
base
+
routes
.
confirm
}
?token=
${
token
}
">
${
process
.
env
.
HOST
}
:
${
process
.
env
.
PORT
}${
html
:
`<a href="
${
process
.
env
.
PROTOCOL
}
://
${
process
.
env
.
HOST
}
:
${
process
.
env
.
PORT
}${
routes
.
base
+
routes
.
confirm
}
?token=
${
token
}
">
${
process
.
env
.
PROTOCOL
}
://
${
process
.
env
.
HOST
}
:
${
process
.
env
.
PORT
}${
routes
.
base
+
routes
.
confirm
}
?token=
${
token
}
</a>`
,
};
...
...
@@ -36,15 +38,9 @@ const postMail = async (email, token) => {
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
});
}
};
...
...
@@ -64,12 +60,12 @@ export const postSignup = async (req, res) => {
body
:
{
email
,
nick_name
},
}
=
req
;
const
result
=
db
.
User
.
findOne
({
const
result
=
await
db
.
User
.
findOne
({
where
:
{
email
:
email
},
logging
:
false
,
});
if
(
result
.
length
!=
0
)
{
if
(
result
)
{
res
.
status
(
statusCode
.
err
).
json
({
msg
:
serverMSG
.
server_err
,
content
:
"
You are aleady registered
"
,
...
...
@@ -84,22 +80,22 @@ export const postSignup = async (req, res) => {
}
};
export
const
postLogin
=
(
req
,
res
)
=>
{
export
const
postLogin
=
async
(
req
,
res
)
=>
{
const
{
body
:
{
email
},
}
=
req
;
const
result
=
db
.
User
.
findAll
({
const
result
=
await
db
.
User
.
findAll
({
where
:
{
email
:
email
},
logging
:
false
,
});
if
(
result
.
length
!=
0
)
{
if
(
result
)
{
// token 발행
const
mail_token
=
jwt
.
sign
(
{
email
:
email
,
nick_name
:
resu
t
l
[
0
][
"
nick_name
"
],
nick_name
:
resul
t
[
0
][
"
nick_name
"
],
},
process
.
env
.
AUTH_SECRETKEY
,
{
...
...
@@ -125,8 +121,11 @@ export const postLogin = (req, res) => {
export
const
getConfirm
=
(
req
,
res
)
=>
{
const
{
params
:
{
token
},
query
:
{
token
},
}
=
req
;
console
.
log
(
`Hi, test token :
${
token
}
`
);
res
.
status
(
statusCode
.
ok
)
.
json
({
msg
:
serverMSG
.
server_ok
,
content
:
`Your token is :
${
token
}
`
});
};
server/src/models/user.js
View file @
a675d529
...
...
@@ -23,10 +23,6 @@ export class User extends Model {
allowNull
:
false
,
unique
:
true
,
},
password
:
{
type
:
DataTypes
.
STRING
(
20
),
allowNull
:
false
,
},
},
{
sequelize
,
...
...
server/src/views/login.pug
View file @
a675d529
block content
.login-form_container
form(action=routes.login, method="post")
form(action=
routes.base +
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
View file @
a675d529
block content
.signup-form_container
form(action = routes.signup, method = "post")
form(action =
routes.base +
routes.signup, method = "post")
input(type="email", name="email", require=true, placeholder="E-mail")
input(type="
number
", name="
locCod
e")
input(type="
text
", name="
nick_nam
e")
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