diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-07-01 16:03:53 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-07-01 16:03:53 +0200 |
commit | 69b0a27cbbd69ca019eb7db5f917b1dd06dc82cd (patch) | |
tree | 8659f819818a3da6419959b6b7838a7f0557c948 /server/models/oauth-client.js | |
parent | a3ee6fa22dee4b68fcde9cd23708b471db446e11 (diff) | |
download | PeerTube-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.js | 33 |
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 @@ | |||
1 | const mongoose = require('mongoose') | ||
2 | |||
3 | // --------------------------------------------------------------------------- | ||
4 | |||
5 | const OAuthClientSchema = mongoose.Schema({ | ||
6 | clientSecret: String, | ||
7 | grants: Array, | ||
8 | redirectUris: Array | ||
9 | }) | ||
10 | |||
11 | OAuthClientSchema.path('clientSecret').required(true) | ||
12 | |||
13 | OAuthClientSchema.statics = { | ||
14 | list: list, | ||
15 | loadByIdAndSecret: loadByIdAndSecret, | ||
16 | loadFirstClient: loadFirstClient | ||
17 | } | ||
18 | |||
19 | mongoose.model('OAuthClient', OAuthClientSchema) | ||
20 | |||
21 | // --------------------------------------------------------------------------- | ||
22 | |||
23 | function list (callback) { | ||
24 | return this.find(callback) | ||
25 | } | ||
26 | |||
27 | function loadFirstClient (callback) { | ||
28 | return this.findOne({}, callback) | ||
29 | } | ||
30 | |||
31 | function loadByIdAndSecret (id, clientSecret) { | ||
32 | return this.findOne({ _id: id, clientSecret: clientSecret }) | ||
33 | } | ||