aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/user.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-07-01 16:03:53 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-07-01 16:03:53 +0200
commit69b0a27cbbd69ca019eb7db5f917b1dd06dc82cd (patch)
tree8659f819818a3da6419959b6b7838a7f0557c948 /server/models/user.js
parenta3ee6fa22dee4b68fcde9cd23708b471db446e11 (diff)
downloadPeerTube-69b0a27cbbd69ca019eb7db5f917b1dd06dc82cd.tar.gz
PeerTube-69b0a27cbbd69ca019eb7db5f917b1dd06dc82cd.tar.zst
PeerTube-69b0a27cbbd69ca019eb7db5f917b1dd06dc82cd.zip
OAuth/User models refractoring -> use mongoose api
Diffstat (limited to 'server/models/user.js')
-rw-r--r--server/models/user.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/server/models/user.js b/server/models/user.js
new file mode 100644
index 000000000..130b49b55
--- /dev/null
+++ b/server/models/user.js
@@ -0,0 +1,28 @@
1const mongoose = require('mongoose')
2
3// ---------------------------------------------------------------------------
4
5const UserSchema = mongoose.Schema({
6 password: String,
7 username: String
8})
9
10UserSchema.path('password').required(true)
11UserSchema.path('username').required(true)
12
13UserSchema.statics = {
14 list: list,
15 loadByUsernameAndPassword: loadByUsernameAndPassword
16}
17
18mongoose.model('User', UserSchema)
19
20// ---------------------------------------------------------------------------
21
22function list (callback) {
23 return this.find(callback)
24}
25
26function loadByUsernameAndPassword (username, password, callback) {
27 return this.findOne({ username: username, password: password }, callback)
28}