aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/user.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-10-01 09:12:02 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-10-01 09:12:02 +0200
commitb81929a0148c8a6a3213acb41b5bd4d1936b66b5 (patch)
tree8c70b24006a778e00b51609e44c956394efa3748 /server/models/user.js
parent0eb78d530376c43d228e3e071e032fe9849149ed (diff)
downloadPeerTube-b81929a0148c8a6a3213acb41b5bd4d1936b66b5.tar.gz
PeerTube-b81929a0148c8a6a3213acb41b5bd4d1936b66b5.tar.zst
PeerTube-b81929a0148c8a6a3213acb41b5bd4d1936b66b5.zip
Server: when we remove a user, remove the oauthtokens too
Diffstat (limited to 'server/models/user.js')
-rw-r--r--server/models/user.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/server/models/user.js b/server/models/user.js
index c2c8807f0..91e8aeae1 100644
--- a/server/models/user.js
+++ b/server/models/user.js
@@ -4,6 +4,8 @@ const customUsersValidators = require('../helpers/custom-validators').users
4const modelUtils = require('./utils') 4const modelUtils = require('./utils')
5const peertubeCrypto = require('../helpers/peertube-crypto') 5const peertubeCrypto = require('../helpers/peertube-crypto')
6 6
7const OAuthToken = mongoose.model('OAuthToken')
8
7// --------------------------------------------------------------------------- 9// ---------------------------------------------------------------------------
8 10
9const UserSchema = mongoose.Schema({ 11const UserSchema = mongoose.Schema({
@@ -46,6 +48,12 @@ UserSchema.pre('save', function (next) {
46 }) 48 })
47}) 49})
48 50
51UserSchema.pre('remove', function (next) {
52 const user = this
53
54 OAuthToken.removeByUserId(user._id, next)
55})
56
49mongoose.model('User', UserSchema) 57mongoose.model('User', UserSchema)
50 58
51// ------------------------------ METHODS ------------------------------ 59// ------------------------------ METHODS ------------------------------