mirror of
https://github.com/standardebooks/web.git
synced 2025-07-12 09:32:24 -04:00
Update FA login flow to handle new login form
This commit is contained in:
parent
8641c57dbf
commit
f69be0ab1b
3 changed files with 35 additions and 23 deletions
|
@ -114,33 +114,37 @@ try{
|
||||||
$driver->get('https://fundraising.fracturedatlas.org/admin/general_support/donations?page=' . $page);
|
$driver->get('https://fundraising.fracturedatlas.org/admin/general_support/donations?page=' . $page);
|
||||||
|
|
||||||
// Check if we need to log in to FA.
|
// Check if we need to log in to FA.
|
||||||
// Wait until the <body> element is visible, then check the current URL.
|
// Wait until the `<body>` element is visible, then check the current URL.
|
||||||
$driver->wait(20, 250)->until(WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::xpath('/html/body')));
|
$driver->wait(20, 250)->until(WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::xpath('/html/body')));
|
||||||
if(stripos($driver->getCurrentURL(), 'auth0.com')){
|
if(stripos($driver->getCurrentURL(), 'auth.fracturedatlas.org')){
|
||||||
|
// We were redirected to the login page, so try to log in.
|
||||||
$log->Write('Logging in to Fractured Atlas ...');
|
$log->Write('Logging in to Fractured Atlas ...');
|
||||||
|
|
||||||
// We were redirected to the login page, so try to log in.
|
|
||||||
/** @var WebDriverElement $emailField */
|
/** @var WebDriverElement $emailField */
|
||||||
$emailField = $driver->wait(20, 250)->until(WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::xpath('//input[@type="email"]')));
|
$emailField = $driver->wait(20, 250)->until(WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::xpath('//input[@inputmode="email"]')));
|
||||||
|
$emailField->sendKeys($faUsername);
|
||||||
|
|
||||||
/** @var WebDriverElement $passwordField */
|
/** @var WebDriverElement $passwordField */
|
||||||
$passwordField = $driver->wait(20, 250)->until(WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::xpath('//input[@type="password"]')));
|
$passwordField = $driver->wait(20, 250)->until(WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::xpath('//input[@type="password"]')));
|
||||||
/** @var WebDriverElement $submitButton */
|
// FA requires an explicit click on the password field for some reason.
|
||||||
$submitButton = $driver->wait(20, 250)->until(WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::xpath('//button[@type="submit"]')));
|
$passwordField->click();
|
||||||
|
$passwordField->clear();
|
||||||
// Fill out and submit the form.
|
|
||||||
$emailField->sendKeys($faUsername);
|
|
||||||
$passwordField->sendKeys($faPassword);
|
$passwordField->sendKeys($faPassword);
|
||||||
$submitButton->click();
|
|
||||||
|
// Submit the form.
|
||||||
|
/** @var WebDriverElement $form */
|
||||||
|
$form = $driver->wait(20, 250)->until(WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::xpath('//form')));
|
||||||
|
$form->submit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait until the page finishes loading.
|
// Wait until the page finishes loading.
|
||||||
// We have to expand the row before we can select its contents, so click the 'expand' button once it's visible.
|
// We have to expand the row before we can select its contents, so click the 'expand' button once it's visible.
|
||||||
try{
|
try{
|
||||||
$toggleButton = $driver->wait(20, 250)->until(WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::xpath('//button[contains(@class, "button-toggle")]')));
|
$driver->wait(20, 250)->until(WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::xpath('//button[contains(@class, "button-toggle")]')));
|
||||||
}
|
}
|
||||||
catch(Exception){
|
catch(Exception $ex){
|
||||||
$log->Write('Error: Couldn\'t load donation list.');
|
$log->Write('Error: Couldn\'t load donation list.');
|
||||||
continue;
|
throw $ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the last seen transaction ID is null, get everything from today.
|
// If the last seen transaction ID is null, get everything from today.
|
||||||
|
@ -205,7 +209,12 @@ try{
|
||||||
}
|
}
|
||||||
|
|
||||||
if($firstTransactionId !== null){
|
if($firstTransactionId !== null){
|
||||||
file_put_contents($transactionFilePath, $firstTransactionId);
|
try{
|
||||||
|
file_put_contents($transactionFilePath, $firstTransactionId);
|
||||||
|
}
|
||||||
|
catch(\Exception){
|
||||||
|
// Might not have the right permissions, pass.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$log->Write('Done.');
|
$log->Write('Done.');
|
||||||
|
|
|
@ -91,21 +91,25 @@ try{
|
||||||
// Check if we need to log in to FA.
|
// Check if we need to log in to FA.
|
||||||
// Wait until the `<body>` element is visible, then check the current URL.
|
// Wait until the `<body>` element is visible, then check the current URL.
|
||||||
$driver->wait(20, 250)->until(WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::xpath('/html/body')));
|
$driver->wait(20, 250)->until(WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::xpath('/html/body')));
|
||||||
if(stripos($driver->getCurrentURL(), 'auth0.com')){
|
if(stripos($driver->getCurrentURL(), 'auth.fracturedatlas.org')){
|
||||||
$log->Write('Logging in to Fractured Atlas ...');
|
$log->Write('Logging in to Fractured Atlas ...');
|
||||||
|
|
||||||
// We were redirected to the login page, so try to log in.
|
// We were redirected to the login page, so try to log in.
|
||||||
/** @var WebDriverElement $emailField */
|
/** @var WebDriverElement $emailField */
|
||||||
$emailField = $driver->wait(20, 250)->until(WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::xpath('//input[@type="email"]')));
|
$emailField = $driver->wait(20, 250)->until(WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::xpath('//input[@inputmode="email"]')));
|
||||||
|
$emailField->sendKeys($faUsername);
|
||||||
|
|
||||||
/** @var WebDriverElement $passwordField */
|
/** @var WebDriverElement $passwordField */
|
||||||
$passwordField = $driver->wait(20, 250)->until(WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::xpath('//input[@type="password"]')));
|
$passwordField = $driver->wait(20, 250)->until(WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::xpath('//input[@type="password"]')));
|
||||||
/** @var WebDriverElement $submitButton */
|
// FA requires an explicit click on the password field for some reason.
|
||||||
$submitButton = $driver->wait(20, 250)->until(WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::xpath('//button[@type="submit"]')));
|
$passwordField->click();
|
||||||
|
$passwordField->clear();
|
||||||
// Fill out and submit the form.
|
|
||||||
$emailField->sendKeys($faUsername);
|
|
||||||
$passwordField->sendKeys($faPassword);
|
$passwordField->sendKeys($faPassword);
|
||||||
$submitButton->click();
|
|
||||||
|
// Submit the form.
|
||||||
|
/** @var WebDriverElement $form */
|
||||||
|
$form = $driver->wait(20, 250)->until(WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::xpath('//form')));
|
||||||
|
$form->submit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait until the page finishes loading.
|
// Wait until the page finishes loading.
|
||||||
|
|
|
@ -33,4 +33,3 @@ $carousel = Db::Query('SELECT * from Ebooks where EbookId in ' . Db::CreateSetSq
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
<?= Template::Footer() ?>
|
<?= Template::Footer() ?>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue