Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add and use constants for session flashes #409

Merged
merged 3 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Fortify.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ class Fortify
*/
public static $registersRoutes = true;

const PASSWORD_UPDATED = 'password-updated';
const PROFILE_INFORMATION_UPDATED = 'profile-information-updated';
const RECOVERY_CODES_GENERATED = 'recovery-codes-generated';
const TWO_FACTOR_AUTHENTICATION_CONFIRMED = 'two-factor-authentication-confirmed';
const TWO_FACTOR_AUTHENTICATION_DISABLED = 'two-factor-authentication-disabled';
const TWO_FACTOR_AUTHENTICATION_ENABLED = 'two-factor-authentication-enabled';
const VERIFICATION_LINK_SENT = 'verification-link-sent';

/**
* Get the username used for authentication.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Laravel\Fortify\Actions\ConfirmTwoFactorAuthentication;
use Laravel\Fortify\Fortify;

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

return $request->wantsJson()
? new JsonResponse('', 200)
: back()->with('status', 'two-factor-authentication-confirmed');
: back()->with('status', Fortify::TWO_FACTOR_AUTHENTICATION_CONFIRMED);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ public function store(Request $request)

return $request->wantsJson()
? new JsonResponse('', 202)
: back()->with('status', 'verification-link-sent');
: back()->with('status', Fortify::VERIFICATION_LINK_SENT);
}
}
3 changes: 2 additions & 1 deletion src/Http/Controllers/ProfileInformationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Laravel\Fortify\Contracts\UpdatesUserProfileInformation;
use Laravel\Fortify\Fortify;

class ProfileInformationController extends Controller
{
Expand All @@ -23,6 +24,6 @@ public function update(Request $request,

return $request->wantsJson()
? new JsonResponse('', 200)
: back()->with('status', 'profile-information-updated');
: back()->with('status', Fortify::PROFILE_INFORMATION_UPDATED);
}
}
3 changes: 2 additions & 1 deletion src/Http/Controllers/RecoveryCodeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Laravel\Fortify\Actions\GenerateNewRecoveryCodes;
use Laravel\Fortify\Fortify;

class RecoveryCodeController extends Controller
{
Expand Down Expand Up @@ -40,6 +41,6 @@ public function store(Request $request, GenerateNewRecoveryCodes $generate)

return $request->wantsJson()
? new JsonResponse('', 200)
: back()->with('status', 'recovery-codes-generated');
: back()->with('status', Fortify::RECOVERY_CODES_GENERATED);
}
}
5 changes: 3 additions & 2 deletions src/Http/Controllers/TwoFactorAuthenticationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Routing\Controller;
use Laravel\Fortify\Actions\DisableTwoFactorAuthentication;
use Laravel\Fortify\Actions\EnableTwoFactorAuthentication;
use Laravel\Fortify\Fortify;

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

return $request->wantsJson()
? new JsonResponse('', 200)
: back()->with('status', 'two-factor-authentication-enabled');
: back()->with('status', Fortify::TWO_FACTOR_AUTHENTICATION_ENABLED);
}

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

return $request->wantsJson()
? new JsonResponse('', 200)
: back()->with('status', 'two-factor-authentication-disabled');
: back()->with('status', Fortify::TWO_FACTOR_AUTHENTICATION_DISABLED);
}
}
3 changes: 2 additions & 1 deletion src/Http/Responses/PasswordUpdateResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Http\JsonResponse;
use Laravel\Fortify\Contracts\PasswordUpdateResponse as PasswordUpdateResponseContract;
use Laravel\Fortify\Fortify;

class PasswordUpdateResponse implements PasswordUpdateResponseContract
{
Expand All @@ -17,6 +18,6 @@ public function toResponse($request)
{
return $request->wantsJson()
? new JsonResponse('', 200)
: back()->with('status', 'password-updated');
: back()->with('status', Fortify::PASSWORD_UPDATED);
}
}