From 8fa2c34fc5172cb6f68f51322e436089ff5545d2 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 7 Jan 2016 15:41:51 -0500 Subject: [PATCH] Deprecated action:user.loggedOut, updated plugin deprecation notices ... to show replacement, if available. --- src/controllers/authentication.js | 5 ++++- src/plugins/hooks.js | 18 ++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/controllers/authentication.js b/src/controllers/authentication.js index 1ffee1c896..47249b18e5 100644 --- a/src/controllers/authentication.js +++ b/src/controllers/authentication.js @@ -280,8 +280,11 @@ authenticationController.logout = function(req, res, next) { } req.logout(); + // action:user.loggedOut deprecated in > v0.9.3 plugins.fireHook('action:user.loggedOut', {req: req, res: res, uid: uid}); - res.status(200).send(''); + plugins.fireHook('static:user.loggedOut', {req: req, res: res, uid: uid}, function() { + res.status(200).send(''); + }); }); } else { res.status(200).send(''); diff --git a/src/plugins/hooks.js b/src/plugins/hooks.js index 3093cbf515..3330608154 100644 --- a/src/plugins/hooks.js +++ b/src/plugins/hooks.js @@ -4,10 +4,11 @@ var winston = require('winston'), async = require('async'); module.exports = function(Plugins) { - Plugins.deprecatedHooks = [ - 'filter:user.delete', - 'filter:user.custom_fields' - ]; + Plugins.deprecatedHooks = { + 'filter:user.delete': 'static:user.delete', + 'filter:user.custom_fields': null, + 'action:user.loggedOut': 'static:user.loggedOut' + }; /* `data` is an object consisting of (* is required): @@ -27,8 +28,13 @@ module.exports = function(Plugins) { var method; - if (Plugins.deprecatedHooks.indexOf(data.hook) !== -1) { - winston.warn('[plugins/' + id + '] Hook `' + data.hook + '` is deprecated, please use an alternative'); + if (Object.keys(Plugins.deprecatedHooks).indexOf(data.hook) !== -1) { + winston.warn('[plugins/' + id + '] Hook `' + data.hook + '` is deprecated, ' + + (Plugins.deprecatedHooks[data.hook] ? + 'please use `' + Plugins.deprecatedHooks[data.hook] + '` instead.' : + 'there is no alternative.' + ) + ); } if (data.hook && data.method) {