diff options
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 | } | ||