aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/oauth-client.js
diff options
context:
space:
mode:
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}