From b81929a0148c8a6a3213acb41b5bd4d1936b66b5 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sat, 1 Oct 2016 09:12:02 +0200 Subject: Server: when we remove a user, remove the oauthtokens too --- server/models/oauth-token.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'server/models/oauth-token.js') diff --git a/server/models/oauth-token.js b/server/models/oauth-token.js index f6a814c36..d53fdcf31 100644 --- a/server/models/oauth-token.js +++ b/server/models/oauth-token.js @@ -20,7 +20,8 @@ OAuthTokenSchema.path('user').required(true) OAuthTokenSchema.statics = { getByRefreshTokenAndPopulateClient: getByRefreshTokenAndPopulateClient, getByTokenAndPopulateUser: getByTokenAndPopulateUser, - getByRefreshToken: getByRefreshToken + getByRefreshToken: getByRefreshToken, + removeByUserId: removeByUserId } mongoose.model('OAuthToken', OAuthTokenSchema) @@ -53,3 +54,7 @@ function getByTokenAndPopulateUser (bearerToken) { function getByRefreshToken (refreshToken) { return this.findOne({ refreshToken: refreshToken }).exec() } + +function removeByUserId (userId, callback) { + return this.remove({ user: userId }, callback) +} -- cgit v1.2.3