diff --git a/src/oidc.js b/src/oidc.js
index fda64a31f..cb6149b7a 100644
--- a/src/oidc.js
+++ b/src/oidc.js
@@ -32,6 +32,7 @@ const assert = require('assert'),
safe = require('safetydance'),
settings = require('./settings.js'),
tokens = require('./tokens.js'),
+ translation = require('./translation.js'),
url = require('url'),
users = require('./users.js'),
util = require('util');
@@ -436,6 +437,8 @@ function renderInteractionPage(provider) {
assert.strictEqual(typeof provider, 'object');
return async function (req, res, next) {
+ const translationAssets = await translation.getTranslations();
+
try {
const { uid, prompt, params, session } = await provider.interactionDetails(req, res);
@@ -457,7 +460,10 @@ function renderInteractionPage(provider) {
options.iconUrl = app.iconUrl;
}
- return res.render('login', options);
+ const template = fs.readFileSync(__dirname + '/oidc_templates/login.ejs', 'utf-8');
+ const html = ejs.render(translation.translate(template, translationAssets.translations || {}, translationAssets.fallback || {}), options);
+
+ return res.send(html);
}
case 'consent': {
const options = {
diff --git a/src/oidc_templates/login.ejs b/src/oidc_templates/login.ejs
index 2f7f893e2..70c60e57b 100644
--- a/src/oidc_templates/login.ejs
+++ b/src/oidc_templates/login.ejs
@@ -4,7 +4,7 @@
-
Login to <%= name %>
+ {{ login.loginTo }} <%= name %>
@@ -59,7 +59,7 @@
-
Login to <%= name %>
+
{{ login.loginTo }} <%= name %>
@@ -67,21 +67,21 @@
@@ -119,11 +119,11 @@ document.getElementById('loginForm').addEventListener('submit', function (event)
if (data.message === 'Username and password does not match') {
document.getElementById('inputPassword').value = '';
document.getElementById('inputPassword').focus();
- document.getElementById('passwordError').innerText = 'Invalid username or password';
+ document.getElementById('passwordError').innerText = '{{ login.errorIncorrectCredentials }}';
} else if (data.message.indexOf('totpToken') !== -1) {
document.getElementById('inputTotpToken').value = '';
document.getElementById('inputTotpToken').focus();
- document.getElementById('totpError').innerText = 'Missing or invalid 2FA Token';
+ document.getElementById('totpError').innerText = '{{ login.errorIncorrect2FAToken }}';
} else {
throw new Error('Something went wrong');
}
@@ -134,7 +134,7 @@ document.getElementById('loginForm').addEventListener('submit', function (event)
if (data.redirectTo) window.location.href = data.redirectTo;
else console.log('login success but missing redirectTo in data:', data);
}).catch(function (error) {
- document.getElementById('passwordError').innerText = 'Unexpected error. Try again later.';
+ document.getElementById('passwordError').innerText = '{{ login.errorInternal }}';
console.warn(error, res);
});
});