Skip to content

Commit

Permalink
Merge pull request #630 from auth0/fix-login-page-allow-no-html
Browse files Browse the repository at this point in the history
Fix: Allow login page to have no html
  • Loading branch information
willvedd authored Aug 23, 2022
2 parents 7b65d9f + 036d1c5 commit afe5e02
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/context/directory/handlers/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function parse(context: DirectoryContext): ParsedPages {
log.warn(`Skipping pages file ${html} as missing the corresponding '.json' file`);
return [];
}
if (!html && key === 'error_page') {
if (!html && ['error_page', 'login'].includes(key)) {
//Error pages don't require an HTML template, it is valid to redirect errors to URL
return {
...loadJSON(meta, context.mappings),
Expand Down
35 changes: 22 additions & 13 deletions test/context/directory/pages.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,34 @@ describe('#directory context pages', () => {
expect(context.assets.pages).to.deep.equal(pagesTarget);
});

it('should process pages even without error_page HTML file', async () => {
it('should process login and error pages without HTML files', async () => {
const repoDir = path.join(testDataDir, 'directory', 'pages4');
const noErrorPageHtml = (() => {
const newPages = { ...pages };
delete newPages['error_page.html'];
return newPages;
})();
createDir(repoDir, { [constants.PAGES_DIRECTORY]: noErrorPageHtml });

const pagesNoHtml = {
'login.json': '{ "name": "login", "enabled": false }',
'error_page.json':
'{ "name": "error_page", "url": "https://example.com/error", "show_log_link": false }',
};

createDir(repoDir, { [constants.PAGES_DIRECTORY]: pagesNoHtml });

const config = { AUTH0_INPUT_FILE: repoDir };
const context = new Context(config, mockMgmtClient());
await context.load();

expect(context.assets.pages.find((page) => page.name === 'error_page')).to.deep.equal({
html: '',
name: 'error_page',
show_log_link: false,
url: 'https://example.com/error',
});
expect(context.assets.pages).to.deep.equal([
{
html: '',
name: 'error_page',
show_log_link: false,
url: 'https://example.com/error',
},
{
html: '',
name: 'login',
enabled: false,
},
]);
});

it('should ignore unknown file', async () => {
Expand Down

0 comments on commit afe5e02

Please sign in to comment.