mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 18:29:27 +02:00
OAuth/User models refractoring -> use mongoose api
This commit is contained in:
parent
a3ee6fa22d
commit
69b0a27cbb
14 changed files with 217 additions and 156 deletions
33
server/models/oauth-client.js
Normal file
33
server/models/oauth-client.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
const mongoose = require('mongoose')
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const OAuthClientSchema = mongoose.Schema({
|
||||
clientSecret: String,
|
||||
grants: Array,
|
||||
redirectUris: Array
|
||||
})
|
||||
|
||||
OAuthClientSchema.path('clientSecret').required(true)
|
||||
|
||||
OAuthClientSchema.statics = {
|
||||
list: list,
|
||||
loadByIdAndSecret: loadByIdAndSecret,
|
||||
loadFirstClient: loadFirstClient
|
||||
}
|
||||
|
||||
mongoose.model('OAuthClient', OAuthClientSchema)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function list (callback) {
|
||||
return this.find(callback)
|
||||
}
|
||||
|
||||
function loadFirstClient (callback) {
|
||||
return this.findOne({}, callback)
|
||||
}
|
||||
|
||||
function loadByIdAndSecret (id, clientSecret) {
|
||||
return this.findOne({ _id: id, clientSecret: clientSecret })
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue