oidcserver: custom templates for device login

the default one uses google fonts :/
This commit is contained in:
Girish Ramakrishnan
2026-03-13 13:21:01 +05:30
parent a3c038781f
commit 6db2b55e63
5 changed files with 117 additions and 1 deletions
+27 -1
View File
@@ -274,6 +274,9 @@ async function cleanupExpired() {
}
}
const TEMPLATE_DEVICE_INPUT = fs.readFileSync(path.join(paths.DASHBOARD_DIR, 'oidc_device_input.html'), 'utf-8');
const TEMPLATE_DEVICE_CONFIRM = fs.readFileSync(path.join(paths.DASHBOARD_DIR, 'oidc_device_confirm.html'), 'utf-8');
const TEMPLATE_DEVICE_SUCCESS = fs.readFileSync(path.join(paths.DASHBOARD_DIR, 'oidc_device_success.html'), 'utf-8');
const TEMPLATE_LOGIN = fs.readFileSync(path.join(paths.DASHBOARD_DIR, 'oidc_login.html'), 'utf-8');
const TEMPLATE_INTERACTION_CONFIRM = fs.readFileSync(path.join(paths.DASHBOARD_DIR, 'oidc_interaction_confirm.html'), 'utf8');
const TEMPLATE_INTERACTION_ABORT = fs.readFileSync(path.join(paths.DASHBOARD_DIR, 'oidc_interaction_abort.html'), 'utf8');
@@ -674,7 +677,30 @@ async function start() {
}
},
devInteractions: { enabled: false },
deviceFlow: { enabled: true, charset: 'base-20', mask: '****-****' },
deviceFlow: {
enabled: true,
charset: 'base-20',
mask: '****-****',
userCodeInputSource: async function (ctx, form, out, err) {
let message;
if (err && (err.userCode || err.name === 'NoCodeError')) {
message = '<p class="red">The code you entered is incorrect. Try again</p>';
} else if (err && err.name === 'AbortedError') {
message = '<p class="red">The sign-in request was interrupted</p>';
} else if (err) {
message = '<p class="red">There was an error processing your request</p>';
} else {
message = '<p>Enter the code displayed on your device</p>';
}
ctx.body = ejs.render(TEMPLATE_DEVICE_INPUT, { message, form });
},
userCodeConfirmSource: async function (ctx, form, client, deviceInfo, userCode) {
ctx.body = ejs.render(TEMPLATE_DEVICE_CONFIRM, { clientName: ctx.oidc.client.clientName || ctx.oidc.client.clientId, userCode, form });
},
successSource: async function (ctx) {
ctx.body = ejs.render(TEMPLATE_DEVICE_SUCCESS, {});
},
},
},
clientDefaults: {
response_types: ['code', 'id_token'],