Add OAuth.deleteUserData method
Removes the user's oAuthId-to-uid mapping from Redis upon user deletion. This fixes an issue where OAuth services could not link to a user if a user account was deleted and then re-created.
This commit is contained in:
parent
f8306923de
commit
5df4097aa0
22
library.js
22
library.js
@ -232,5 +232,27 @@
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
OAuth.deleteUserData = function(uid) {
|
||||||
|
db.getObject('oAuthid:uid', function(err, oAuthData) {
|
||||||
|
if (err) {
|
||||||
|
winston.error('Could not fetch OAuthId data from Redis. Error: ' + err);
|
||||||
|
}
|
||||||
|
var oAuthIdToDelete;
|
||||||
|
for (var oAuthId in oAuthData) {
|
||||||
|
if (oAuthData.hasOwnProperty(oAuthId) && oAuthData[oAuthId] === uid) {
|
||||||
|
oAuthIdToDelete = oAuthId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (typeof oAuthIdToDelete !== 'undefined') {
|
||||||
|
// Delete the oAuthId-to-uid mapping for the user
|
||||||
|
db.deleteObjectField('oAuthid:uid', oAuthIdToDelete, function(err, numDeletes) {
|
||||||
|
if (err) {
|
||||||
|
winston.error('Could not remove OAuthId data for uid ' + uid + '. Error: ' + err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = OAuth;
|
module.exports = OAuth;
|
||||||
}(module));
|
}(module));
|
@ -6,6 +6,7 @@
|
|||||||
"library": "./library.js",
|
"library": "./library.js",
|
||||||
"hooks": [
|
"hooks": [
|
||||||
{ "hook": "action:app.load", "method": "init" },
|
{ "hook": "action:app.load", "method": "init" },
|
||||||
|
{ "hook": "action:user.delete", "method": "deleteUserData" },
|
||||||
{ "hook": "filter:auth.init", "method": "getStrategy" },
|
{ "hook": "filter:auth.init", "method": "getStrategy" },
|
||||||
{ "hook": "filter:admin.header.build", "method": "addMenuItem" }
|
{ "hook": "filter:admin.header.build", "method": "addMenuItem" }
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user