1
0
Fork 0
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:
Chocobozzz 2016-07-01 16:03:53 +02:00
parent a3ee6fa22d
commit 69b0a27cbb
14 changed files with 217 additions and 156 deletions

28
server/models/user.js Normal file
View 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)
}