Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

nateritter's avatar

Overwrite Illuminate Auth trait?

Using Spark v2, we implemented an is_temp_password field in our users table, and by default set that to 1 when creating a new user. We created our own API call to handle a custom form to reset passwords in some cases, but I wanted to set that value to 0 if the user uses the default Spark "forgot password" or "password reset" features.

I see I can use Spark::swap perhaps for the internal password reset function, and just modify that, but the forgot password feature is an Illuminate\Foundation\Auth\ResetsPassword trait. I assume I can't swap that, so what would be the best way to go about hooking in or modifying the use of one method and adding that field to the resetPassword($user, $password) method in there?

0 likes
2 replies
nateritter's avatar

Actually, I guess I can't modify the Http/Controllers/Settings/Security/PasswordController's update() method using Spark::swap since it doesn't use interact. I guess I have two questions now then.

  1. What's the best way to add in functionality to set is_temp_password => 0 when using the forgot password feature (being an Illuminate trait)?

  2. Same question, but for the internal password reset feature? (being a non-interacted controller method)?

nateritter's avatar
nateritter
OP
Best Answer
Level 3

Thanks to @Cronix and @muzak on the Slack Larachat #spark channel, they pointed me in the direction of a good solution: to take the controllers and traits, copy them to my own app, change the use references accordingly, and then overwrite the Spark routes (by moving my own RouteServiceProvider to be after the SparkServiceProvider in the config/app.php).

Doing all that was quick and painless, and allowed me to customize the methods which update the passwords to include the is_temp_password change as well.

++ to the Laravel community once again.

1 like

Please or to participate in this conversation.