2016-07-01 09:03:53 -05:00
|
|
|
const mongoose = require('mongoose')
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
const OAuthClientSchema = mongoose.Schema({
|
|
|
|
clientSecret: String,
|
|
|
|
grants: Array,
|
|
|
|
redirectUris: Array
|
|
|
|
})
|
|
|
|
|
|
|
|
OAuthClientSchema.path('clientSecret').required(true)
|
|
|
|
|
|
|
|
OAuthClientSchema.statics = {
|
2016-07-20 09:23:58 -05:00
|
|
|
getByIdAndSecret: getByIdAndSecret,
|
2016-07-01 09:03:53 -05:00
|
|
|
list: list,
|
|
|
|
loadFirstClient: loadFirstClient
|
|
|
|
}
|
|
|
|
|
|
|
|
mongoose.model('OAuthClient', OAuthClientSchema)
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
function list (callback) {
|
|
|
|
return this.find(callback)
|
|
|
|
}
|
|
|
|
|
|
|
|
function loadFirstClient (callback) {
|
|
|
|
return this.findOne({}, callback)
|
|
|
|
}
|
|
|
|
|
2016-07-20 09:23:58 -05:00
|
|
|
function getByIdAndSecret (id, clientSecret) {
|
2016-07-27 14:15:07 -05:00
|
|
|
return this.findOne({ _id: id, clientSecret: clientSecret }).exec()
|
2016-07-01 09:03:53 -05:00
|
|
|
}
|