File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ) ;
Original file line number Diff line number Diff line change 1- import { type Connection } from '@salesforce/core' ;
1+ import { Org , type Connection } from '@salesforce/core' ;
22import { type Page } from 'playwright' ;
33import { waitForPageErrors } from '../browserforce.js' ;
44
5- const FRONT_DOOR_PATH = '/secur/frontdoor.jsp' ;
65const POST_LOGIN_PATH = '/setup/forcecomHomepage.apexp' ;
76
87export 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 }
You can’t perform that action at this time.
0 commit comments