Skip to content

Commit a88b515

Browse files
djaissclaude
andcommitted
fix: only show deletion notice when APP_SHOW_DELETION_NOTICE is enabled
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 6dca9ef commit a88b515

5 files changed

Lines changed: 44 additions & 0 deletions

File tree

‎.env.example‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ APP_URL=http://localhost:8000
3030
# Can be true or false. Default to false.
3131
APP_DISABLE_SIGNUP=false
3232

33+
# Show a notice on the login page warning that this instance and all its data
34+
# will be deleted. Only meant for the hosted instance. Default to false.
35+
APP_SHOW_DELETION_NOTICE=false
36+
3337
# Database to store information
3438
# The documentation is here: https://laravel.com/docs/10.x/database
3539
# You can also see the different values you can use in config/database.php

‎app/Http/Controllers/Auth/LoginController.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public function __invoke(Request $request): Response
4343
'wallpaperUrl' => WallpaperHelper::getRandomWallpaper(),
4444
'providers' => $providers,
4545
'beta' => $request->cookie('beta') !== 'false',
46+
'showDeletionNotice' => (bool) config('monica.show_deletion_notice'),
4647
]);
4748
}
4849

‎config/monica.php‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@
2323
*/
2424
'disable_signup' => (bool) env('APP_DISABLE_SIGNUP', false),
2525

26+
/*
27+
|--------------------------------------------------------------------------
28+
| Show instance deletion notice
29+
|--------------------------------------------------------------------------
30+
|
31+
| Displays a notice on the login page warning users that this instance
32+
| and all its data will be deleted. Meant for the hosted instance only.
33+
|
34+
*/
35+
'show_deletion_notice' => (bool) env('APP_SHOW_DELETION_NOTICE', false),
36+
2637
/*
2738
|--------------------------------------------------------------------------
2839
| Commit hash of the application

‎resources/js/Pages/Auth/Login.vue‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const props = defineProps({
2323
userless: Boolean,
2424
autologin: Boolean,
2525
beta: Boolean,
26+
showDeletionNotice: Boolean,
2627
});
2728
const webauthn = ref(false);
2829
const publicKeyRef = ref(null);
@@ -89,6 +90,7 @@ const useWebauthn = () => {
8990
</h1>
9091

9192
<div
93+
v-if="showDeletionNotice"
9294
role="alert"
9395
class="mt-6 flex w-full items-start gap-3 border border-amber-200 bg-amber-50 px-6 py-4 text-sm text-amber-900 dark:border-amber-800 dark:bg-amber-950 dark:text-amber-100 rounded-lg sm:max-w-4xl">
9496
<TriangleAlert class="h-5 w-5 shrink-0 text-amber-600 dark:text-amber-400" aria-hidden="true" />

‎tests/Feature/Auth/AuthenticationTest.php‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use App\Models\User;
66
use Illuminate\Foundation\Testing\DatabaseTransactions;
7+
use Inertia\Testing\AssertableInertia as Assert;
78
use PHPUnit\Framework\Attributes\Test;
89
use Tests\TestCase;
910

@@ -21,6 +22,31 @@ public function login_screen_can_be_rendered()
2122
$response->assertStatus(200);
2223
}
2324

25+
#[Test]
26+
public function deletion_notice_is_hidden_by_default()
27+
{
28+
$this->withoutVite();
29+
30+
$this->get('/login')
31+
->assertInertia(fn (Assert $page) => $page
32+
->component('Auth/Login', false)
33+
->where('showDeletionNotice', false)
34+
);
35+
}
36+
37+
#[Test]
38+
public function deletion_notice_is_shown_when_enabled()
39+
{
40+
$this->withoutVite();
41+
config(['monica.show_deletion_notice' => true]);
42+
43+
$this->get('/login')
44+
->assertInertia(fn (Assert $page) => $page
45+
->component('Auth/Login', false)
46+
->where('showDeletionNotice', true)
47+
);
48+
}
49+
2450
#[Test]
2551
public function users_can_authenticate_using_the_login_screen()
2652
{

0 commit comments

Comments
 (0)