// When a user is not logged in and a matching SocialAccount exists,
// Simply log the user into the application.
if (!$isLoggedIn && $socialAccount !== null) {
- $this->loginService->login($socialAccount->user, $socialAccount);
+ $this->loginService->login($socialAccount->user, $socialDriver);
return redirect()->intended('/');
}
namespace Tests\Auth;
+use BookStack\Actions\ActivityType;
use BookStack\Auth\SocialAccount;
use BookStack\Auth\User;
use DB;
]);
$resp = $this->followingRedirects()->get('/login/service/github/callback');
$resp->assertDontSee('login-form');
+ $this->assertActivityExists(ActivityType::AUTH_LOGIN, null, 'github; (' . $this->getAdmin()->id . ') ' . $this->getAdmin()->name);
}
public function test_social_account_detach()
* Assert that an activity entry exists of the given key.
* Checks the activity belongs to the given entity if provided.
*/
- protected function assertActivityExists(string $type, Entity $entity = null)
+ protected function assertActivityExists(string $type, ?Entity $entity, ?string $detail)
{
$detailsToCheck = ['type' => $type];
$detailsToCheck['entity_id'] = $entity->id;
}
+ if ($detail) {
+ $detailsToCheck['detail'] = $detail;
+ }
+
$this->assertDatabaseHas('activities', $detailsToCheck);
}
}