1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 02:39:33 +02:00

Server: when we remove a user, remove the oauthtokens too

This commit is contained in:
Chocobozzz 2016-10-01 09:12:02 +02:00
parent 0eb78d5303
commit b81929a014
2 changed files with 14 additions and 1 deletions

View file

@ -4,6 +4,8 @@ const customUsersValidators = require('../helpers/custom-validators').users
const modelUtils = require('./utils')
const peertubeCrypto = require('../helpers/peertube-crypto')
const OAuthToken = mongoose.model('OAuthToken')
// ---------------------------------------------------------------------------
const UserSchema = mongoose.Schema({
@ -46,6 +48,12 @@ UserSchema.pre('save', function (next) {
})
})
UserSchema.pre('remove', function (next) {
const user = this
OAuthToken.removeByUserId(user._id, next)
})
mongoose.model('User', UserSchema)
// ------------------------------ METHODS ------------------------------