Provide custom logout views
This commit is contained in:
+15
-34
@@ -21,6 +21,7 @@ const assert = require('assert'),
|
||||
BoxError = require('./boxerror.js'),
|
||||
database = require('./database.js'),
|
||||
debug = require('debug')('box:oidc'),
|
||||
ejs = require('ejs'),
|
||||
fs = require('fs'),
|
||||
middleware = require('./middleware'),
|
||||
path = require('path'),
|
||||
@@ -492,44 +493,24 @@ async function claims(userId, use, scope) {
|
||||
return claims;
|
||||
}
|
||||
|
||||
// @param form - form source (id="op.logoutForm") to be embedded in the page and submitted by the End-User
|
||||
async function logoutSource(ctx, form) {
|
||||
// @param ctx - koa request context
|
||||
// @param form - form source (id="op.logoutForm") to be embedded in the page and submitted by
|
||||
// the End-User
|
||||
ctx.body = `<!DOCTYPE html>
|
||||
<head>
|
||||
<title>Logout Request</title>
|
||||
<style>/* css and html classes omitted for brevity, see lib/helpers/defaults.js */</style>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<h1>Cloudron Do you want to sign-out from ${ctx.host}?</h1>
|
||||
${form}
|
||||
<button autofocus type="submit" form="op.logoutForm" value="yes" name="logout">Yes, sign me out</button>
|
||||
<button type="submit" form="op.logoutForm">No, stay signed in</button>
|
||||
</div>
|
||||
</body>
|
||||
</html>`;
|
||||
const data = {
|
||||
host: settings.dashboardFqdn(),
|
||||
form
|
||||
};
|
||||
|
||||
ctx.body = ejs.render(fs.readFileSync(path.join(__dirname, 'oidc_templates/logout.ejs'), 'utf8'), data, {});
|
||||
}
|
||||
|
||||
async function postLogoutSuccessSource(ctx) {
|
||||
// @param ctx - koa request context
|
||||
const {
|
||||
clientId, clientName, clientUri, initiateLoginUri, logoUri, policyUri, tosUri,
|
||||
} = ctx.oidc.client || {}; // client is defined if the user chose to stay logged in with the OP
|
||||
const display = clientName || clientId;
|
||||
ctx.body = `<!DOCTYPE html>
|
||||
<head>
|
||||
<title>Sign-out Success</title>
|
||||
<style>/* css and html classes omitted for brevity, see lib/helpers/defaults.js */</style>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<h1>Cloudron Sign-out Success</h1>
|
||||
<p>Your sign-out ${display ? `with ${display}` : ''} was successful.</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>`;
|
||||
const { clientId, clientName, clientUri, initiateLoginUri, logoUri, policyUri, tosUri } = ctx.oidc.client || {}; // client is defined if the user chose to stay logged in with the OP
|
||||
const display = clientName || clientId;
|
||||
const data = {
|
||||
dashboardOrigin: settings.dashboardOrigin()
|
||||
};
|
||||
|
||||
ctx.body = ejs.render(fs.readFileSync(path.join(__dirname, 'oidc_templates/post_logout.ejs'), 'utf8'), data, {});
|
||||
}
|
||||
|
||||
async function getProvider(routePrefix) {
|
||||
|
||||
Reference in New Issue
Block a user