mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 02:39:33 +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
28
server/models/user.js
Normal file
28
server/models/user.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
const mongoose = require('mongoose')
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const UserSchema = mongoose.Schema({
|
||||
password: String,
|
||||
username: String
|
||||
})
|
||||
|
||||
UserSchema.path('password').required(true)
|
||||
UserSchema.path('username').required(true)
|
||||
|
||||
UserSchema.statics = {
|
||||
list: list,
|
||||
loadByUsernameAndPassword: loadByUsernameAndPassword
|
||||
}
|
||||
|
||||
mongoose.model('User', UserSchema)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function list (callback) {
|
||||
return this.find(callback)
|
||||
}
|
||||
|
||||
function loadByUsernameAndPassword (username, password, callback) {
|
||||
return this.findOne({ username: username, password: password }, callback)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue