Fix tenant admin Google OAuth redirect
This commit is contained in:
@@ -69,6 +69,34 @@ class TenantAdminGoogleControllerTest extends TestCase
|
||||
$this->assertAuthenticatedAs($user);
|
||||
}
|
||||
|
||||
public function test_callback_ignores_intended_and_uses_admin_fallback(): void
|
||||
{
|
||||
$tenant = Tenant::factory()->create();
|
||||
$user = User::factory()->create([
|
||||
'tenant_id' => $tenant->id,
|
||||
'role' => 'tenant_admin',
|
||||
]);
|
||||
|
||||
$socialiteUser = tap(new SocialiteUser)->map([
|
||||
'id' => 'google-id-456',
|
||||
'name' => 'Google Tenant Admin',
|
||||
'email' => $user->email,
|
||||
]);
|
||||
|
||||
$driver = Mockery::mock();
|
||||
Socialite::shouldReceive('driver')->once()->with('google')->andReturn($driver);
|
||||
$driver->shouldReceive('user')->once()->andReturn($socialiteUser);
|
||||
|
||||
$this->withSession([
|
||||
'url.intended' => '/packages',
|
||||
]);
|
||||
|
||||
$response = $this->get('/event-admin/auth/google/callback');
|
||||
|
||||
$response->assertRedirect('/event-admin/dashboard');
|
||||
$this->assertAuthenticatedAs($user);
|
||||
}
|
||||
|
||||
public function test_callback_redirects_back_when_user_not_found(): void
|
||||
{
|
||||
$socialiteUser = tap(new SocialiteUser)->map([
|
||||
|
||||
Reference in New Issue
Block a user