Toggle navigation
Toggle navigation
This project
Loading...
Sign in
강연욱
/
myYoutube
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
2
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Flare-k
2020-06-12 02:59:04 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
1f3f6a50e84483d2710ca7c0d82d4f63a66c795e
1f3f6a50
1 parent
323907ae
[Modified] User controller Join
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletions
controllers/userController.js
passport.js
controllers/userController.js
View file @
1f3f6a5
import
routes
from
"../routes"
;
import
User
from
"../models/User"
;
// 회원가입 -> 완료 -> 홈화면으로 Redirect
export
const
getJoin
=
(
req
,
res
)
=>
{
res
.
render
(
"join"
,
{
pageTitle
:
"Join"
});
};
export
const
postJoin
=
(
req
,
res
)
=>
{
export
const
postJoin
=
async
(
req
,
res
)
=>
{
const
{
body
:
{
name
,
email
,
password
,
password2
},
}
=
req
;
...
...
@@ -12,6 +13,15 @@ export const postJoin = (req, res) => {
res
.
status
(
400
);
res
.
render
(
"join"
,
{
pageTitle
:
"Join"
});
}
else
{
try
{
const
user
=
await
User
.
create
({
name
,
email
,
});
await
User
.
register
(
user
,
password
);
}
catch
(
error
)
{
console
.
log
(
error
);
}
// To Do: Register User
// To Do: Log user in
res
.
redirect
(
routes
.
home
);
...
...
passport.js
View file @
1f3f6a5
...
...
@@ -4,3 +4,6 @@ import User from "./models/User";
// passport에게 strategy(로그인 방식)를 사용하도록 요청한다.
// passportLocalMongooser가 제공하는 strategy를 이용한다. -> username과 password를 사용.
passport
.
use
(
User
.
createStrategy
());
passport
.
serializeUser
(
User
.
serializeUser
());
passport
.
deserializeUser
(
User
.
deserializeUser
());
...
...
Please
register
or
login
to post a comment