Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Force Selecting Account when logging in via the CLI #2484

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/up.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export default class UpCommand extends AbstractServerCommand {
.withOrg(org)
.withSiteLoginUrl(
// TODO switch to production URL
`https://admin.hlx.page/login/${org}/${site}/main?client_id=aem-cli&redirect_uri=${encodeURIComponent(`http://localhost:${this._httpPort}/.aem/cli/login/ack`)}`,
`https://admin.hlx.page/login/${org}/${site}/main?client_id=aem-cli&redirect_uri=${encodeURIComponent(`http://localhost:${this._httpPort}/.aem/cli/login/ack`)}&selectAccount=true`,
);
}

Expand Down
12 changes: 6 additions & 6 deletions test/server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,21 +286,21 @@
try {
// Delete accept header due to nock conflict
delete req.headers.accept;
console.log('http proxy request', req.url);

Check warning on line 289 in test/server.test.js

View workflow job for this annotation

GitHub Actions / Test

Unexpected console statement
const resp = await h1NoCache().fetch(req.url, {});
console.log('http proxy response for', req.url, resp.status);

Check warning on line 291 in test/server.test.js

View workflow job for this annotation

GitHub Actions / Test

Unexpected console statement
res.writeHead(resp.status, resp.headers.plain());
res.write(await resp.buffer());
res.end();
proxyRequests.push(req.url);
} catch (e) {
console.error('http proxy error:', e);

Check warning on line 297 in test/server.test.js

View workflow job for this annotation

GitHub Actions / Test

Unexpected console statement
res.writeHead(500);
res.end();
}
})
.listen(8002, '127.0.0.1', () => {
console.log('http proxy server listening on port 8002');

Check warning on line 303 in test/server.test.js

View workflow job for this annotation

GitHub Actions / Test

Unexpected console statement
resolve(p);
});
});
Expand Down Expand Up @@ -450,7 +450,7 @@
.withCwd(cwd)
.withHttpPort(3000)
.withProxyUrl('http://main--foo--bar.aem.page')
.withSiteLoginUrl('https://admin.hlx.page/login/bar/foo/main?client_id=aem-cli&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2F.aem%2Fcli%2Flogin%2Fack');
.withSiteLoginUrl('https://admin.hlx.page/login/bar/foo/main?client_id=aem-cli&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2F.aem%2Fcli%2Flogin%2Fack&selectAccount=true');

await project.init();
project.log.level = 'silly';
Expand All @@ -463,7 +463,7 @@
});
assert.strictEqual(resp.status, 302);
assert.ok(
resp.headers.get('location').startsWith('https://admin.hlx.page/login/bar/foo/main?client_id=aem-cli&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2F.aem%2Fcli%2Flogin%2Fack&state='),
resp.headers.get('location').startsWith('https://admin.hlx.page/login/bar/foo/main?client_id=aem-cli&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2F.aem%2Fcli%2Flogin%2Fack&selectAccount=true&state='),
);
} finally {
await project.stop();
Expand All @@ -476,7 +476,7 @@
.withCwd(cwd)
.withHttpPort(3000)
.withProxyUrl('http://main--foo--bar.aem.page')
.withSiteLoginUrl('https://admin.hlx.page/login/bar/foo/main?client_id=aem-cli&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2F.aem%2Fcli%2Flogin%2Fack');
.withSiteLoginUrl('https://admin.hlx.page/login/bar/foo/main?client_id=aem-cli&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2F.aem%2Fcli%2Flogin%2Fack&selectAccount=true');

await project.init();
project.log.level = 'silly';
Expand Down Expand Up @@ -509,7 +509,7 @@
.withCwd(cwd)
.withHttpPort(3000)
.withProxyUrl('http://main--foo--bar.aem.page')
.withSiteLoginUrl('https://admin.hlx.page/login/bar/foo/main?client_id=aem-cli&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2F.aem%2Fcli%2Flogin%2Fack');
.withSiteLoginUrl('https://admin.hlx.page/login/bar/foo/main?client_id=aem-cli&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2F.aem%2Fcli%2Flogin%2Fack&selectAccount=true');

await project.init();
project.log.level = 'silly';
Expand Down Expand Up @@ -591,7 +591,7 @@
.withCwd(cwd)
.withHttpPort(3000)
.withProxyUrl('http://main--foo--bar.aem.page')
.withSiteLoginUrl('https://admin.hlx.page/login/bar/foo/main?client_id=aem-cli&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2F.aem%2Fcli%2Flogin%2Fack');
.withSiteLoginUrl('https://admin.hlx.page/login/bar/foo/main?client_id=aem-cli&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2F.aem%2Fcli%2Flogin%2Fack&selectAccount=true');

await project.init();
project.log.level = 'silly';
Expand Down Expand Up @@ -637,7 +637,7 @@
.withCwd(cwd)
.withHttpPort(3000)
.withProxyUrl('http://main--foo--bar.aem.page')
.withSiteLoginUrl('https://admin.hlx.page/login/bar/foo/main?client_id=aem-cli&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2F.aem%2Fcli%2Flogin%2Fack');
.withSiteLoginUrl('https://admin.hlx.page/login/bar/foo/main?client_id=aem-cli&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2F.aem%2Fcli%2Flogin%2Fack&selectAccount=true');

await project.init();
project.log.level = 'silly';
Expand Down
4 changes: 2 additions & 2 deletions test/up-cmd.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ describe('Integration test for up command with helix pages', function suite() {
resp.headers
.get('location')
.startsWith(
'https://admin.hlx.page/login/adobe/dummy-foo/main?client_id=aem-cli&redirect_uri=http%3A%2F%2Flocalhost%3A0%2F.aem%2Fcli%2Flogin%2Fack&state=',
'https://admin.hlx.page/login/adobe/dummy-foo/main?client_id=aem-cli&redirect_uri=http%3A%2F%2Flocalhost%3A0%2F.aem%2Fcli%2Flogin%2Fack&selectAccount=true&state=',
),
);
} catch (e) {
Expand Down Expand Up @@ -256,7 +256,7 @@ describe('Integration test for up command with helix pages', function suite() {
resp.headers
.get('location')
.startsWith(
'https://admin.hlx.page/login/adobe/dummy/main?client_id=aem-cli&redirect_uri=http%3A%2F%2Flocalhost%3A0%2F.aem%2Fcli%2Flogin%2Fack&state=',
'https://admin.hlx.page/login/adobe/dummy/main?client_id=aem-cli&redirect_uri=http%3A%2F%2Flocalhost%3A0%2F.aem%2Fcli%2Flogin%2Fack&selectAccount=true&state=',
),
);
} catch (e) {
Expand Down