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:55:25 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
323907ae0378bedca7af901a5f34f7b06c2ab54b
323907ae
1 parent
0d375133
[Add] passport and User model
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
0 deletions
init.js
models/User.js
package.json
passport.js
init.js
View file @
323907a
...
...
@@ -3,6 +3,7 @@ import app from "./app"; // app.js에서 export default app했기 때문에 불
import
"./db"
;
import
"./models/Video"
;
import
"./models/Comment"
;
import
"./models/User"
;
dotenv
.
config
();
...
...
models/User.js
0 → 100644
View file @
323907a
import
mongoose
from
"mongoose"
;
import
passportLocalMongoose
from
"passport-local-mongoose"
;
const
UserSchema
=
new
mongoose
.
Schema
({
name
:
String
,
email
:
String
,
avatarUrl
:
String
,
facebookId
:
Number
,
githubId
:
Number
,
});
// 이 상태에서 새로운 스키마를 추가한다.
// passportLocalMongoose는 configuration object가 필요하다.
// passportLocalMongoose의 옵션에 usernameField가 있다. 이는 username이 될 field를 명시해준다.
// passportLocalMongoose에게 어떤 Field를 username으로 사용할 것인지 알려줘야 한다.
// usernameField로 이메일을 사용하기로 하겠다.
UserSchema
.
plugin
(
passportLocalMongoose
,
{
usernameField
:
"email"
});
const
model
=
mongoose
.
model
(
"User"
,
UserSchema
);
export
default
model
;
package.json
View file @
323907a
...
...
@@ -32,6 +32,9 @@
"morgan"
:
"^1.10.0"
,
"multer"
:
"^1.4.2"
,
"node-sass"
:
"^4.14.1"
,
"passport"
:
"^0.4.1"
,
"passport-local"
:
"^1.0.0"
,
"passport-local-mongoose"
:
"^6.0.1"
,
"postcss-loader"
:
"^3.0.0"
,
"pug"
:
"^2.0.4"
,
"sass-loader"
:
"^8.0.2"
,
...
...
passport.js
0 → 100644
View file @
323907a
import
passport
from
"passport"
;
import
User
from
"./models/User"
;
// passport에게 strategy(로그인 방식)를 사용하도록 요청한다.
// passportLocalMongooser가 제공하는 strategy를 이용한다. -> username과 password를 사용.
passport
.
use
(
User
.
createStrategy
());
Please
register
or
login
to post a comment