aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/oauth-client.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/oauth-client.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/oauth-client.js')
-rw-r--r--server/models/oauth-client.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/server/models/oauth-client.js b/server/models/oauth-client.js
new file mode 100644
index 000000000..048e5af48
--- /dev/null
+++ b/server/models/oauth-client.js
@@ -0,0 +1,33 @@
1const mongoose = require('mongoose')
2
3// ---------------------------------------------------------------------------
4
5const OAuthClientSchema = mongoose.Schema({
6 clientSecret: String,
7 grants: Array,
8 redirectUris: Array
9})
10
11OAuthClientSchema.path('clientSecret').required(true)
12
13OAuthClientSchema.statics = {
14 list: list,
15 loadByIdAndSecret: loadByIdAndSecret,
16 loadFirstClient: loadFirstClient
17}
18
19mongoose.model('OAuthClient', OAuthClientSchema)
20
21// ---------------------------------------------------------------------------
22
23function list (callback) {
24 return this.find(callback)
25}
26
27function loadFirstClient (callback) {
28 return this.findOne({}, callback)
29}
30
31function loadByIdAndSecret (id, clientSecret) {
32 return this.findOne({ _id: id, clientSecret: clientSecret })
33}