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

pllaguno's avatar

Error when deployed but works local

I have a laravel app that in my local machine works fine and when i deploy it to aws i get errors. The part i am getting errors is the following. My app has admin users which create new users, when the user is creted an email is sent to them with a link and a token for them to pick their password. the problem is once they pick their password when the post is clicked i get the following error.

Argument 2 passed to Illuminate\Auth\Passwords\PasswordBroker::__construct() must implement interface Illuminate\Contracts\Auth\UserProvider, null given, called in /var/app/current/vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBrokerManager.php on line 75

the relevant code for the post is the following:

public function reset(Request $request)
    {
        $request->validate($this->rules(), $this->validationErrorMessages());


        // Here we will attempt to reset the user's password. If it is successful we
        // will update the password on an actual user model and persist it to the
        // database. Otherwise we will parse the error and return the response.
        
        $response = $this->broker()->reset(
            $this->credentials($request), function ($user, $password) {
                $this->resetPassword($user, $password);
            }
        );
        
        // If the password was successfully reset, we will redirect the user back to
        // the application's home authenticated view. If there is an error we can
        // redirect them back to where they came from with their error message.
        return $response == Password::PASSWORD_RESET
                    ? $this->sendResetResponse($request, $response)
                    : $this->sendResetFailedResponse($request, $response);
    }
    protected function rules()
    {
        return [
            'token' => 'required',
            'email' => 'required|email',
            'password' => 'required|confirmed|min:8',
        ];
    }

    /**
     * Get the password reset validation error messages.
     *
     * @return array
     */
    protected function validationErrorMessages()
    {
        return [];
    }
    /**
     * Get the password reset credentials from the request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    protected function credentials(Request $request)
    {
        
        return $request->only(
            'email', 'password', 'password_confirmation', 'token'
        );
    }

    /**
     * Reset the given user's password.
     *
     * @param  \Illuminate\Contracts\Auth\CanResetPassword  $user
     * @param  string  $password
     * @return void
     */
    protected function resetPassword($user, $password)
    {
        $user->password = Hash::make($password);

        $user->setRememberToken(Str::random(60));

        $user->save();

        event(new PasswordReset($user));

        $this->guard()->login($user);
    }

    /**
     * Get the response for a successful password reset.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  string  $response
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
     */
    protected function sendResetResponse(Request $request, $response)
    {
        return redirect($this->redirectPath())
                            ->with('status', trans($response));
    }

    /**
     * Get the response for a failed password reset.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  string  $response
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
     */
    protected function sendResetFailedResponse(Request $request, $response)
    {
        return redirect()->back()
                    ->withInput($request->only('email'))
                    ->withErrors(['email' => trans($response)]);
    }

    /**
     * Get the broker to be used during password reset.
     *
     * @return \Illuminate\Contracts\Auth\PasswordBroker
     */
    public function broker()
    {
        return Password::broker('newusers');
    }

    /**
     * Get the guard to be used during password reset.
     *
     * @return \Illuminate\Contracts\Auth\StatefulGuard
     */
    protected function guard()
    {
        return Auth::guard();
    }
0 likes
5 replies
jlrdw's avatar

Just a quick thought on it have you checked your letter case Linux is case sensitive.

pllaguno's avatar

I'm really confused on why would this happen. How can my local copy work flawlessy. There is another issue where i don't know if it is related. When deploying this to AWS elastic beanstalk i am having directory permission issues where i have to give storage and bootstrap 777 chmod.

jlrdw's avatar
jlrdw
Best Answer
Level 75

I don't know how you place the files on the server. But of course check and make sure your config files are correct.

Maybe a setting that worked in development that needs changing for production.

Same with .env, double check it.

1 like
pllaguno's avatar

It appears that on my local machine it did work because i had some kind of cache, since I cleared cache and then it also gave me that error on my local machine.

Please or to participate in this conversation.