Skip to content

Commit dd603cd

Browse files
committed
fix: bug where admins without 2fa were sent to 2fa challenge on relogin
1 parent 36bd614 commit dd603cd

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

library.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@ plugin.addRoutes = async ({ router, middleware, helpers }) => {
188188
});
189189
};
190190

191+
plugin.appendConfig = async (config) => {
192+
const hasKey = await plugin.hasKey(config.uid);
193+
config['2factor'] = { hasKey };
194+
return config;
195+
};
196+
191197
plugin.addAdminNavigation = function (header, callback) {
192198
translator.translate('[[2factor:title]]', (title) => {
193199
header.plugins.push({

plugin.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"hooks": [
66
{ "hook": "static:app.load", "method": "init" },
77
{ "hook": "static:api.routes", "method": "addRoutes" },
8+
{ "hook": "filter:config.get", "method": "appendConfig" },
89
{ "hook": "filter:admin.header.build", "method": "addAdminNavigation" },
910
{ "hook": "filter:user.profileMenu", "method": "addProfileItem" },
1011
{ "hook": "response:router.page", "method": "check" },

static/lib/main.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
(async () => {
44
const hooks = await app.require('hooks');
55
hooks.on('filter:admin.reauth', (data) => {
6-
data.url = `/login/2fa?next=/${ajaxify.currentPage}`;
6+
if (config['2factor'].hasKey) {
7+
data.url = `/login/2fa?next=/${ajaxify.currentPage}`;
8+
}
9+
710
return data;
811
});
912
})();

0 commit comments

Comments
 (0)