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:
parent
0eb78d5303
commit
b81929a014
2 changed files with 14 additions and 1 deletions
|
@ -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 ------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue