找不到网址,点击Gmail中的密码重置链接

时间:2019-04-28 08:04:40

标签: laravel

重置密码链接时出现错误“单击gmail-http://localhost/password/reset/8fa85663874bce909623d285a255b976730d9ac509867c55fd820f78b176bfd5中的重置链接时,在此URL上找不到对象”

ResetPasswordController.php

protected function redirectTo()
{
    if (auth()->user()->is_admin == 1) {
        return 'admin/home';
    } elseif (auth()->user()->is_admin == 2) {
        return 'designpages/index';
    } else {
        return 'designpages/index';
    }
}

public function __construct()
{
    $this->middleware('guest');
}

view.php

<form method="POST" action="/password/reset" class="account_form">
    @csrf

    <input type="hidden" name="token" value="{{ $token }}">
    <div class="field-form">
        <input id="email" type="email" class="field-text{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email"
               value="{{ old('email') }}" placeholder="E-Mail Address" required autofocus>

        @if ($errors->has('email'))
            <span class="invalid-feedback" role="alert">
                <strong>{{ $errors->first('email') }}</strong>
            </span>
        @endif
    </div>
    <div class="field-form">
        <input id="password" type="password" class="field-text{{ $errors->has('password') ? ' is-invalid' : '' }}"
               name="password" placeholder="Password" required>
        @if ($errors->has('password'))
            <span class="invalid-feedback" role="alert">
                <strong>{{ $errors->first('password') }}</strong>
            </span>
        @endif
    </div>

    <div class="field-form">
        <input id="password-confirm" type="password" class="field-text" name="password_confirmation"
               placeholder="Confirm Password" required>
    </div>
    <div class="field-form field-submit">
        <button type="submit" class="awe-btn awe-btn-13">
            {{ __('Reset Password') }}
        </button>
    </div>
</form>

1 个答案:

答案 0 :(得分:1)

好的,我明白了。正如您在url中看到的那样,有您的文件夹名称,并且缺少public。因此会产生错误。“ http://localhost/password/reset/8fa85663874bce909623d285a255b976730d9ac509867c55fd820f78b176bfd5

'/someurl'    // its makes a proper url when we mount our project folder as document root in apache2 server. otherwise its gives your wrong url -- "http://localhost/password/reset"
url('/someurl');  // by using this gives you correct url -- "http://localhost/yourfolder/public/reset/password"

solution =如果我们不使用url()助手。然后在.env文件中编辑您的APP_URL。

APP_URL=http://localhost/yourfolder/public

然后点击

php artisan config:clear