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
cfde81bf
Commit
cfde81bf
authored
Jul 19, 2021
by
KangMin An
Browse files
Update : Edit Signup & Login Process.
parent
e7ff22ad
Changes
1
Hide whitespace changes
Inline
Side-by-side
server/src/controllers/userController.js
View file @
cfde81bf
import
db
from
"
../db/index
"
;
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
postMail
=
async
(
email
,
token
)
=>
{
const
transporter
=
nodemailer
.
createTransport
({
service
:
process
.
env
.
NODEMAILER_SERVICE
,
auth
:
{
...
...
@@ -56,4 +42,62 @@ export const postSignup = async (req, res) => {
}
};
export
const
postLogin
=
(
req
,
res
)
=>
{};
// 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
result
=
db
.
User
.
findOne
({
where
:
{
email
:
email
},
logging
:
false
,
});
if
(
result
)
{
res
.
status
(
statusCode
.
err
).
json
({
msg
:
serverMSG
.
server_err
,
content
:
"
You are aleady registered
"
,
});
}
else
{
db
.
User
.
create
({
email
:
email
,
locCode
:
locCode
},
{
logging
:
false
});
// 로그인 페이지로 넘겨주기.
}
};
export
const
postLogin
=
(
req
,
res
)
=>
{
const
{
body
:
{
email
},
}
=
req
;
const
result
=
db
.
User
.
findOne
({
where
:
{
email
:
email
},
logging
:
false
,
});
if
(
result
)
{
// token 발행
const
token
=
"
ex Token
"
;
// 토큰이 포함된 로그인 링크 전송
postLogin
(
email
,
token
);
res
.
status
(
statusCode
.
ok
)
.
json
({
msg
:
serverMSG
.
server_ok
,
content
:
"
Send Mail Successfully.
"
});
}
else
{
res
.
status
(
statusCode
.
err
)
.
json
({
msg
:
serverMSG
.
server_err
,
content
:
"
You are still not our user.
"
,
});
}
};
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