fix(notifications): point the new login in-app url at account.security

This commit is contained in:
dualfroz committed 2026-10-02 16:39:14 +02:00
1 parent 09d0159805
commit 1dcb00b39f
3 files changed
+60 -1

No files matched your search

@@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
DB::table('notification_templates')
->where('key', 'new_login_detected')
->where('in_app_url', '{{ route("profile.security") }}')
->update(['in_app_url' => '{{ route("account.security") }}']);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
DB::table('notification_templates')
->where('key', 'new_login_detected')
->where('in_app_url', '{{ route("account.security") }}')
->update(['in_app_url' => '{{ route("profile.security") }}']);
}
};
+1 -1
View File
@@ -30,7 +30,7 @@ class EmailTemplateSeeder extends Seeder
'mail_enabled' => 'force',
'in_app_enabled' => 'choice_off',
'edit_preference_message' => 'Alert me about new login attempts',
'in_app_url' => '{{ route("profile.security") }}',
'in_app_url' => '{{ route("account.security") }}',
],
'new_invoice_created' => [
'subject' => 'New invoice created',
+30
View File
@@ -3,6 +3,7 @@
namespace Tests\Feature\Auth;
use App\Livewire\Auth\Login;
use App\Models\NotificationTemplate;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Hash;
@@ -56,6 +57,35 @@ class LoginTest extends TestCase
$this->assertAuthenticated();
}
/**
* Test if a login from a new ip sends the in-app alert to a user who opted in
*/
public function test_can_login_with_in_app_new_login_alert_enabled()
{
$user = User::factory()->create([
'email' => 'tests@paymenter.org',
'password' => Hash::make('password'),
]);
$user->notificationsPreferences()->create([
'notification_template_id' => NotificationTemplate::where('key', 'new_login_detected')->value('id'),
'mail_enabled' => true,
'in_app_enabled' => true,
]);
Livewire::test(Login::class)
->set('email', 'tests@paymenter.org')
->set('password', 'password')
->call('submit')
->assertHasNoErrors()
->assertRedirect(route('dashboard'));
$this->assertDatabaseHas('notifications', [
'user_id' => $user->id,
'url' => route('account.security'),
]);
}
/**
* Test if the user can't login with valid credentials but wrong captcha
*/