Skip to content

Commit

Permalink
Merge pull request #13 from fumikito/enhancement/change-loggedin-cond…
Browse files Browse the repository at this point in the history
…ition

Change login condition
  • Loading branch information
miya0001 authored Oct 20, 2017
2 parents 4bfbe9e + 30d266f commit e38bbfa
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/Context/RawWordPressContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,19 @@ public function login( $user, $password )
$submit->click();

for ( $i = 0; $i < $this->timeout; $i++ ) {
// Check if keeping staying on login page till timeout.
try {
$admin_url = $this->get_admin_url() . '/';
if ( $this->is_current_url( $admin_url ) ) {
return true;
if ( $this->is_current_url( '/wp-login.php' ) ) {
// Still in login page.
if ( $this->getSession()->getPage()->find( 'css','#login_error' ) ) {
// Find error dialog. Apparent Error.
return false;
} else {
// @todo Should consider other situations?
}
} else {
return false;
// Redirected. Guess logged in.
return true;
}
} catch ( \Exception $e ) {
// do nothing
Expand Down

0 comments on commit e38bbfa

Please sign in to comment.