Skip to content

Commit e594775

Browse files
Add and use constants for session flashes (#409)
* Add and use constants for session flashes * Apply StyleCI patch * formatting Co-authored-by: Taylor Otwell <[email protected]>
1 parent 07e766a commit e594775

7 files changed

+20
-7
lines changed

src/Fortify.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ class Fortify
4545
*/
4646
public static $registersRoutes = true;
4747

48+
const PASSWORD_UPDATED = 'password-updated';
49+
const PROFILE_INFORMATION_UPDATED = 'profile-information-updated';
50+
const RECOVERY_CODES_GENERATED = 'recovery-codes-generated';
51+
const TWO_FACTOR_AUTHENTICATION_CONFIRMED = 'two-factor-authentication-confirmed';
52+
const TWO_FACTOR_AUTHENTICATION_DISABLED = 'two-factor-authentication-disabled';
53+
const TWO_FACTOR_AUTHENTICATION_ENABLED = 'two-factor-authentication-enabled';
54+
const VERIFICATION_LINK_SENT = 'verification-link-sent';
55+
4856
/**
4957
* Get the username used for authentication.
5058
*

src/Http/Controllers/ConfirmedTwoFactorAuthenticationController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Illuminate\Http\Request;
77
use Illuminate\Routing\Controller;
88
use Laravel\Fortify\Actions\ConfirmTwoFactorAuthentication;
9+
use Laravel\Fortify\Fortify;
910

1011
class ConfirmedTwoFactorAuthenticationController extends Controller
1112
{
@@ -22,6 +23,6 @@ public function store(Request $request, ConfirmTwoFactorAuthentication $confirm)
2223

2324
return $request->wantsJson()
2425
? new JsonResponse('', 200)
25-
: back()->with('status', 'two-factor-authentication-confirmed');
26+
: back()->with('status', Fortify::TWO_FACTOR_AUTHENTICATION_CONFIRMED);
2627
}
2728
}

src/Http/Controllers/EmailVerificationNotificationController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ public function store(Request $request)
2727

2828
return $request->wantsJson()
2929
? new JsonResponse('', 202)
30-
: back()->with('status', 'verification-link-sent');
30+
: back()->with('status', Fortify::VERIFICATION_LINK_SENT);
3131
}
3232
}

src/Http/Controllers/ProfileInformationController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Illuminate\Http\Request;
77
use Illuminate\Routing\Controller;
88
use Laravel\Fortify\Contracts\UpdatesUserProfileInformation;
9+
use Laravel\Fortify\Fortify;
910

1011
class ProfileInformationController extends Controller
1112
{
@@ -23,6 +24,6 @@ public function update(Request $request,
2324

2425
return $request->wantsJson()
2526
? new JsonResponse('', 200)
26-
: back()->with('status', 'profile-information-updated');
27+
: back()->with('status', Fortify::PROFILE_INFORMATION_UPDATED);
2728
}
2829
}

src/Http/Controllers/RecoveryCodeController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Illuminate\Http\Request;
77
use Illuminate\Routing\Controller;
88
use Laravel\Fortify\Actions\GenerateNewRecoveryCodes;
9+
use Laravel\Fortify\Fortify;
910

1011
class RecoveryCodeController extends Controller
1112
{
@@ -40,6 +41,6 @@ public function store(Request $request, GenerateNewRecoveryCodes $generate)
4041

4142
return $request->wantsJson()
4243
? new JsonResponse('', 200)
43-
: back()->with('status', 'recovery-codes-generated');
44+
: back()->with('status', Fortify::RECOVERY_CODES_GENERATED);
4445
}
4546
}

src/Http/Controllers/TwoFactorAuthenticationController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Routing\Controller;
88
use Laravel\Fortify\Actions\DisableTwoFactorAuthentication;
99
use Laravel\Fortify\Actions\EnableTwoFactorAuthentication;
10+
use Laravel\Fortify\Fortify;
1011

1112
class TwoFactorAuthenticationController extends Controller
1213
{
@@ -23,7 +24,7 @@ public function store(Request $request, EnableTwoFactorAuthentication $enable)
2324

2425
return $request->wantsJson()
2526
? new JsonResponse('', 200)
26-
: back()->with('status', 'two-factor-authentication-enabled');
27+
: back()->with('status', Fortify::TWO_FACTOR_AUTHENTICATION_ENABLED);
2728
}
2829

2930
/**
@@ -39,6 +40,6 @@ public function destroy(Request $request, DisableTwoFactorAuthentication $disabl
3940

4041
return $request->wantsJson()
4142
? new JsonResponse('', 200)
42-
: back()->with('status', 'two-factor-authentication-disabled');
43+
: back()->with('status', Fortify::TWO_FACTOR_AUTHENTICATION_DISABLED);
4344
}
4445
}

src/Http/Responses/PasswordUpdateResponse.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Http\JsonResponse;
66
use Laravel\Fortify\Contracts\PasswordUpdateResponse as PasswordUpdateResponseContract;
7+
use Laravel\Fortify\Fortify;
78

89
class PasswordUpdateResponse implements PasswordUpdateResponseContract
910
{
@@ -17,6 +18,6 @@ public function toResponse($request)
1718
{
1819
return $request->wantsJson()
1920
? new JsonResponse('', 200)
20-
: back()->with('status', 'password-updated');
21+
: back()->with('status', Fortify::PASSWORD_UPDATED);
2122
}
2223
}

0 commit comments

Comments
 (0)