PeerTube/server/models/oauth-client.js

34 lines
782 B
JavaScript
Raw Normal View History

const mongoose = require('mongoose')
// ---------------------------------------------------------------------------
const OAuthClientSchema = mongoose.Schema({
clientSecret: String,
grants: Array,
redirectUris: Array
})
OAuthClientSchema.path('clientSecret').required(true)
OAuthClientSchema.statics = {
2016-07-20 16:23:58 +02:00
getByIdAndSecret: getByIdAndSecret,
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 16:23:58 +02:00
function getByIdAndSecret (id, clientSecret) {
return this.findOne({ _id: id, clientSecret: clientSecret })
}