laravel / fortify

Backend controllers and scaffolding for Laravel authentication.

Home Page:https://laravel.com/docs/fortify

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use constants for status changes in the session

dwightwatson opened this issue · comments

This is semi-related to #341 but more specifically about having to do string comparisons on the session to present the correct messaging to users. I'm working on migrating to Fortify without Jetstream so I'm involved in the nitty-gritty deals of rolling my own UI.

I wonder if perhaps these session strings could be abstracted into constants. It would make the abstraction less leaky (and I don't need to worry about internal changes to Fortify), with the added benefit of making it clear that this status change is coming out of Fortify.

// Could we ditch this...
@if (session('status') == 'two-factor-authentication-enabled')

// ...for this?
@if (session('status') === Fortify::TWO_FACTOR_AUTHENTICATION_ENABLED)

Fortify does this in a number of places (including password updates, profile updates and verification links being updated) but my specific interest is the interactions with 2FA.

Happy to PR this if you're open to the change.

Yeah feel free to try a PR. Worst case you could still use the constants in your own project 👍

In general these strings shouldn't change so if you ever spot a change feel free to let us know. Thanks