mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-05-05 16:50:12 +00:00
Fixed social auth login audit log messages
Was logging the whole social account instance instead of just the method. Updated tests to cover. Fixes #2930
This commit is contained in:
parent
8565187138
commit
8a7408bd31
3 changed files with 8 additions and 2 deletions
|
@ -141,7 +141,7 @@ class SocialAuthService
|
||||||
// When a user is not logged in and a matching SocialAccount exists,
|
// When a user is not logged in and a matching SocialAccount exists,
|
||||||
// Simply log the user into the application.
|
// Simply log the user into the application.
|
||||||
if (!$isLoggedIn && $socialAccount !== null) {
|
if (!$isLoggedIn && $socialAccount !== null) {
|
||||||
$this->loginService->login($socialAccount->user, $socialAccount);
|
$this->loginService->login($socialAccount->user, $socialDriver);
|
||||||
|
|
||||||
return redirect()->intended('/');
|
return redirect()->intended('/');
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Tests\Auth;
|
namespace Tests\Auth;
|
||||||
|
|
||||||
|
use BookStack\Actions\ActivityType;
|
||||||
use BookStack\Auth\SocialAccount;
|
use BookStack\Auth\SocialAccount;
|
||||||
use BookStack\Auth\User;
|
use BookStack\Auth\User;
|
||||||
use DB;
|
use DB;
|
||||||
|
@ -82,6 +83,7 @@ class SocialAuthTest extends TestCase
|
||||||
]);
|
]);
|
||||||
$resp = $this->followingRedirects()->get('/login/service/github/callback');
|
$resp = $this->followingRedirects()->get('/login/service/github/callback');
|
||||||
$resp->assertDontSee('login-form');
|
$resp->assertDontSee('login-form');
|
||||||
|
$this->assertActivityExists(ActivityType::AUTH_LOGIN, null, 'github; (' . $this->getAdmin()->id . ') ' . $this->getAdmin()->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_social_account_detach()
|
public function test_social_account_detach()
|
||||||
|
|
|
@ -62,7 +62,7 @@ abstract class TestCase extends BaseTestCase
|
||||||
* Assert that an activity entry exists of the given key.
|
* Assert that an activity entry exists of the given key.
|
||||||
* Checks the activity belongs to the given entity if provided.
|
* 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 = ['type' => $type];
|
||||||
|
|
||||||
|
@ -71,6 +71,10 @@ abstract class TestCase extends BaseTestCase
|
||||||
$detailsToCheck['entity_id'] = $entity->id;
|
$detailsToCheck['entity_id'] = $entity->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($detail) {
|
||||||
|
$detailsToCheck['detail'] = $detail;
|
||||||
|
}
|
||||||
|
|
||||||
$this->assertDatabaseHas('activities', $detailsToCheck);
|
$this->assertDatabaseHas('activities', $detailsToCheck);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue