feat: add TRYPOST_GOOGLE_AUTH_ENABLED toggle to show/hide Google login on auth pages

This commit is contained in:
Paulo Castellano 2026-04-01 15:27:26 -03:00
parent 6e86b83433
commit 57df5d5253
5 changed files with 39 additions and 20 deletions

View file

@ -47,6 +47,7 @@ public function share(Request $request): array
'name' => $name,
])->values()->all(),
'selfHosted' => config('trypost.self_hosted'),
'googleAuthEnabled' => config('trypost.google_auth_enabled'),
];
}
}

View file

@ -16,6 +16,18 @@
'self_hosted' => env('SELF_HOSTED', true),
/*
|--------------------------------------------------------------------------
| Google Authentication
|--------------------------------------------------------------------------
|
| Enable or disable "Login with Google" on the login and register pages.
| Disable this if you don't have Google OAuth credentials configured.
|
*/
'google_auth_enabled' => env('TRYPOST_GOOGLE_AUTH_ENABLED', false),
/*
|--------------------------------------------------------------------------
| Social Platforms

View file

@ -66,16 +66,18 @@ defineProps<{
</Button>
</div>
<div
class="relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t after:border-border"
>
<span class="relative z-10 bg-background px-2 text-muted-foreground">{{ $t('auth.or_continue_with') }}</span>
</div>
<template v-if="$page.props.googleAuthEnabled">
<div
class="relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t after:border-border"
>
<span class="relative z-10 bg-background px-2 text-muted-foreground">{{ $t('auth.or_continue_with') }}</span>
</div>
<Button variant="outline" class="w-full" as="a" :href="googleRedirect.url()">
<img src="/images/social/google.svg" alt="Google" class="size-4" />
{{ $t('auth.google_login') }}
</Button>
<Button variant="outline" class="w-full" as="a" :href="googleRedirect.url()">
<img src="/images/social/google.svg" alt="Google" class="size-4" />
{{ $t('auth.google_login') }}
</Button>
</template>
<div class="text-center text-sm text-muted-foreground">
{{ $t('auth.login.no_account') }}

View file

@ -123,16 +123,18 @@ const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
</Button>
</div>
<div
class="relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t after:border-border"
>
<span class="relative z-10 bg-background px-2 text-muted-foreground">{{ $t('auth.or_continue_with') }}</span>
</div>
<template v-if="$page.props.googleAuthEnabled">
<div
class="relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t after:border-border"
>
<span class="relative z-10 bg-background px-2 text-muted-foreground">{{ $t('auth.or_continue_with') }}</span>
</div>
<Button variant="outline" class="w-full" as="a" :href="googleRedirect.url()">
<img src="/images/social/google.svg" alt="Google" class="size-4" />
{{ $t('auth.google_signup') }}
</Button>
<Button variant="outline" class="w-full" as="a" :href="googleRedirect.url()">
<img src="/images/social/google.svg" alt="Google" class="size-4" />
{{ $t('auth.google_signup') }}
</Button>
</template>
<div class="text-center text-sm text-muted-foreground">
{{ $t('auth.register.has_account') }}

View file

@ -29,8 +29,10 @@
Route::get('/reset-password/{token}', [NewPasswordController::class, 'create'])->name('password.reset');
Route::post('/reset-password', [NewPasswordController::class, 'store'])->name('password.store');
Route::get('/auth/google/redirect', [SocialLoginController::class, 'redirect'])->name('auth.google.redirect');
Route::get('/auth/google/callback', [SocialLoginController::class, 'callback'])->name('auth.google.callback');
if (config('trypost.google_auth_enabled')) {
Route::get('/auth/google/redirect', [SocialLoginController::class, 'redirect'])->name('auth.google.redirect');
Route::get('/auth/google/callback', [SocialLoginController::class, 'callback'])->name('auth.google.callback');
}
});
Route::middleware(['auth'])->group(function () {