Skip to content

Commit 1e5b408

Browse files
committed
fix: replace custom implementation with org.getFrontDoorUrl()
1 parent 3063d1a commit 1e5b408

2 files changed

Lines changed: 4 additions & 12 deletions

File tree

src/browserforce.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ export class Browserforce {
2929
}
3030

3131
public async login(): Promise<Browserforce> {
32-
try {
33-
await this.connection.refreshAuth();
34-
} catch (e) {
35-
throw new Error('login failed', { cause: e });
36-
}
3732
await using page = await this.browserContext.newPage();
3833
const loginPage = new LoginPage(page);
3934
await loginPage.login(this.connection);

src/pages/login.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { type Connection } from '@salesforce/core';
1+
import { Org, type Connection } from '@salesforce/core';
22
import { type Page } from 'playwright';
33
import { waitForPageErrors } from '../browserforce.js';
44

5-
const FRONT_DOOR_PATH = '/secur/frontdoor.jsp';
65
const POST_LOGIN_PATH = '/setup/forcecomHomepage.apexp';
76

87
export class LoginPage {
@@ -13,11 +12,9 @@ export class LoginPage {
1312
}
1413

1514
async login(connection: Connection) {
16-
await this.page.goto(
17-
`${connection.instanceUrl.replace(/\/$/, '')}${FRONT_DOOR_PATH}?sid=${
18-
connection.accessToken
19-
}&retURL=${encodeURIComponent(POST_LOGIN_PATH)}`,
20-
);
15+
const org = await Org.create({ connection });
16+
const frontDoorUrl = await org.getFrontDoorUrl(POST_LOGIN_PATH);
17+
await this.page.goto(frontDoorUrl);
2118
await Promise.race([this.page.waitForURL((url) => url.pathname === POST_LOGIN_PATH), waitForPageErrors(this.page)]);
2219
return this;
2320
}

0 commit comments

Comments
 (0)