laravel应用程序部署到AWS时停止工作

时间:2019-05-22 00:07:35

标签: laravel amazon-web-services

我有一个laravel应用程序,在我的本地计算机上运行良好,当我将其部署到AWS时出现错误。我遇到错误的部分如下。我的应用程序具有创建新用户的管理员用户,创建用户时,会向他们发送一封电子邮件,其中包含链接和令牌,供他们选择密码。问题是,一旦他们单击帖子后他们选择了密码,就会出现以下错误。

在我的本地计算机上,PHP版本是7.2.3 Windows。而且AWS有7.2.13弹性beantalk

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

该帖子的相关代码如下:

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();
    }

1 个答案:

答案 0 :(得分:2)

检查您的配置auth.php文件。引发错误的代码是这个

return new PasswordBroker(
    $this->createTokenRepository($config),
    $this->app['auth']->createUserProvider($config['provider'] ?? null)
);

第二个参数为空,也许是因为缺少配置?