Skip to content

Commit 88cae66

Browse files
committed
merge fixes from main
2 parents 6bdc13c + 4317f62 commit 88cae66

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2178
-793
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88

99
CHANGELOG.md export-ignore
1010
README.md export-ignore
11+
.github/workflows/browser-tests.yml export-ignore
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: browser-tests
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
- main
8+
pull_request:
9+
branches:
10+
- develop
11+
- main
12+
13+
jobs:
14+
ci:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Setup PHP
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: 8.4
25+
tools: composer:v2
26+
coverage: xdebug
27+
28+
- name: Setup Node
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: '22'
32+
cache: 'npm'
33+
34+
- name: Install Node Dependencies
35+
run: npm ci
36+
37+
- name: Install Playwright Dependencies
38+
run: npm install playwright@latest
39+
40+
- name: Install Playwright Browsers
41+
run: npx playwright install --with-deps
42+
43+
- name: Add `laravel-labs/starter-kit-browser-tests` Repository
44+
run: |
45+
composer config repositories.browser-tests '{"type": "vcs", "url": "https://github.com/laravel-labs/starter-kit-browser-tests"}' --file composer.json
46+
composer remove "phpunit/phpunit" --dev --no-update
47+
composer require "laravel-labs/starter-kit-browser-tests:dev-main@dev" --dev --no-update
48+
49+
- name: Install Dependencies
50+
run: composer install --no-interaction --prefer-dist --optimize-autoloader
51+
52+
- name: Copy Environment File
53+
run: cp .env.example .env
54+
55+
- name: Generate Application Key
56+
run: php artisan key:generate
57+
58+
- name: Setup Test Environment
59+
run: |
60+
cp vendor/laravel-labs/starter-kit-browser-tests/phpunit.xml.dist .
61+
rm phpunit.xml
62+
rm -Rf tests/
63+
cp -rf vendor/laravel-labs/starter-kit-browser-tests/tests/ tests/
64+
65+
- name: Build Assets
66+
run: npm run build
67+
68+
- name: Tests
69+
run: php vendor/bin/pest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
/resources/js/routes
1111
/resources/js/wayfinder
1212
/vendor
13+
.DS_Store
1314
.env
1415
.env.backup
1516
.env.production

.prettierrc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,16 @@
33
"singleQuote": true,
44
"singleAttributePerLine": false,
55
"htmlWhitespaceSensitivity": "css",
6-
"printWidth": 150,
7-
"plugins": ["prettier-plugin-organize-imports", "prettier-plugin-tailwindcss"],
8-
"tailwindFunctions": ["clsx", "cn", "cva"],
6+
"printWidth": 80,
7+
"plugins": [
8+
"prettier-plugin-organize-imports",
9+
"prettier-plugin-tailwindcss"
10+
],
11+
"tailwindFunctions": [
12+
"clsx",
13+
"cn",
14+
"cva"
15+
],
916
"tailwindStylesheet": "resources/css/app.css",
1017
"tabWidth": 4,
1118
"overrides": [
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Settings;
4+
5+
use App\Http\Controllers\Controller;
6+
use App\Http\Requests\Settings\TwoFactorAuthenticationRequest;
7+
use Illuminate\Routing\Controllers\HasMiddleware;
8+
use Illuminate\Routing\Controllers\Middleware;
9+
use Inertia\Inertia;
10+
use Inertia\Response;
11+
use Laravel\Fortify\Features;
12+
13+
class TwoFactorAuthenticationController extends Controller implements HasMiddleware
14+
{
15+
/**
16+
* Get the middleware that should be assigned to the controller.
17+
*/
18+
public static function middleware(): array
19+
{
20+
return Features::optionEnabled(Features::twoFactorAuthentication(), 'confirmPassword')
21+
? [new Middleware('password.confirm', only: ['show'])]
22+
: [];
23+
}
24+
25+
/**
26+
* Show the user's two-factor authentication settings page.
27+
*/
28+
public function show(TwoFactorAuthenticationRequest $request): Response
29+
{
30+
$request->ensureStateIsValid();
31+
32+
return Inertia::render('settings/TwoFactor', [
33+
'twoFactorEnabled' => $request->user()->hasEnabledTwoFactorAuthentication(),
34+
'requiresConfirmation' => Features::optionEnabled(Features::twoFactorAuthentication(), 'confirm'),
35+
]);
36+
}
37+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace App\Http\Requests\Settings;
4+
5+
use Illuminate\Foundation\Http\FormRequest;
6+
use Laravel\Fortify\Features;
7+
use Laravel\Fortify\InteractsWithTwoFactorState;
8+
9+
class TwoFactorAuthenticationRequest extends FormRequest
10+
{
11+
use InteractsWithTwoFactorState;
12+
13+
/**
14+
* Determine if the user is authorized to make this request.
15+
*/
16+
public function authorize(): bool
17+
{
18+
return Features::enabled(Features::twoFactorAuthentication());
19+
}
20+
21+
/**
22+
* Get the validation rules that apply to the request.
23+
*
24+
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
25+
*/
26+
public function rules(): array
27+
{
28+
return [];
29+
}
30+
}

app/Models/User.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ protected function casts(): array
4444
return [
4545
'email_verified_at' => 'datetime',
4646
'password' => 'hashed',
47+
'two_factor_confirmed_at' => 'datetime',
4748
];
4849
}
4950
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?php
2+
3+
namespace App\Providers;
4+
5+
use App\Actions\Fortify\CreateNewUser;
6+
use App\Actions\Fortify\ResetUserPassword;
7+
use Illuminate\Cache\RateLimiting\Limit;
8+
use Illuminate\Http\Request;
9+
use Illuminate\Support\Facades\RateLimiter;
10+
use Illuminate\Support\ServiceProvider;
11+
use Illuminate\Support\Str;
12+
use Inertia\Inertia;
13+
use Laravel\Fortify\Features;
14+
use Laravel\Fortify\Fortify;
15+
16+
class FortifyServiceProvider extends ServiceProvider
17+
{
18+
/**
19+
* Register any application services.
20+
*/
21+
public function register(): void
22+
{
23+
//
24+
}
25+
26+
/**
27+
* Bootstrap any application services.
28+
*/
29+
public function boot(): void
30+
{
31+
$this->configureActions();
32+
$this->configureViews();
33+
$this->configureRateLimiting();
34+
}
35+
36+
/**
37+
* Configure Fortify actions.
38+
*/
39+
private function configureActions(): void
40+
{
41+
Fortify::resetUserPasswordsUsing(ResetUserPassword::class);
42+
Fortify::createUsersUsing(CreateNewUser::class);
43+
}
44+
45+
/**
46+
* Configure Fortify views.
47+
*/
48+
private function configureViews(): void
49+
{
50+
Fortify::loginView(fn (Request $request) => Inertia::render('auth/Login', [
51+
'canResetPassword' => Features::enabled(Features::resetPasswords()),
52+
'canRegister' => Features::enabled(Features::registration()),
53+
'status' => $request->session()->get('status'),
54+
]));
55+
56+
Fortify::resetPasswordView(fn (Request $request) => Inertia::render('auth/ResetPassword', [
57+
'email' => $request->email,
58+
'token' => $request->route('token'),
59+
]));
60+
61+
Fortify::requestPasswordResetLinkView(fn (Request $request) => Inertia::render('auth/ForgotPassword', [
62+
'status' => $request->session()->get('status'),
63+
]));
64+
65+
Fortify::verifyEmailView(fn (Request $request) => Inertia::render('auth/VerifyEmail', [
66+
'status' => $request->session()->get('status'),
67+
]));
68+
69+
Fortify::registerView(fn () => Inertia::render('auth/Register'));
70+
71+
Fortify::twoFactorChallengeView(fn () => Inertia::render('auth/TwoFactorChallenge'));
72+
73+
Fortify::confirmPasswordView(fn () => Inertia::render('auth/ConfirmPassword'));
74+
}
75+
76+
/**
77+
* Configure rate limiting.
78+
*/
79+
private function configureRateLimiting(): void
80+
{
81+
RateLimiter::for('two-factor', function (Request $request) {
82+
return Limit::perMinute(5)->by($request->session()->get('login.id'));
83+
});
84+
85+
RateLimiter::for('login', function (Request $request) {
86+
$throttleKey = Str::transliterate(Str::lower($request->input(Fortify::username())).'|'.$request->ip());
87+
88+
return Limit::perMinute(5)->by($throttleKey);
89+
});
90+
}
91+
}

config/services.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@
1818
'token' => env('POSTMARK_TOKEN'),
1919
],
2020

21+
'resend' => [
22+
'key' => env('RESEND_KEY'),
23+
],
24+
2125
'ses' => [
2226
'key' => env('AWS_ACCESS_KEY_ID'),
2327
'secret' => env('AWS_SECRET_ACCESS_KEY'),
2428
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
2529
],
2630

27-
'resend' => [
28-
'key' => env('RESEND_KEY'),
29-
],
30-
3131
'slack' => [
3232
'notifications' => [
3333
'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'),

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import prettier from 'eslint-config-prettier';
1+
import prettier from 'eslint-config-prettier/flat';
22
import vue from 'eslint-plugin-vue';
33

44
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript';

0 commit comments

Comments
 (0)