拜托,我是新来的拉拉威尔;我有一个重置密码链接在我的login.blade.php
文件,但其他链接都很好,除了忘记密码链接。每当它被点击,它似乎想刷新页面,并返回到同一页。我得到404上validate.js作为错误的chrome。
我尝试使用Laravel文档在web.php
中重写路由。尝试使用这个,但它不起作用,所以我注解了它:
//Route::get('/forgot-password', function () { return view('auth.forget-password'); })-\>middleware('guest')-\>name('password.request');
我的login.blade.php
文件的一部分:
<div class="form-group">
<button class="mt-4 btn btn-primary" type="submit">Login</button>
</div>
<div class="mb-3 text-center">
<small class="mb-2 text-center ">Forget your Password <a href="{{ route('password.request') }}" class="ml-1 link">Reset.</a> </small>
<small class="text-center ">Dont have an Account yet? <a href="{{route('register')}}" class="ml-1 link">Sign up.</a> </small>
</div>
<div class="text-center">
<hr>
<small class="text-center ">© Copyright {{date('Y')}} {{$settings->site_name}} All Rights Reserved.</small>
</div>
</form>
这是我的web.php,路径如下:
Route::get('/forgot-password', 'App\Http\Controllers\UsersController@forgotpassword')->name('password.request');
尝试使用这个,但它不工作,所以我注解出来:
//Route::get('/forgot-password', function () { return view('auth.forget-password'); })->middleware('guest')->name('password.request');
这是我的forgot-password.blade.php
:
@include('home.assetss')
<body class="d-flex flex-column h-100 auth-page">
<!-- ======= Loginup Section ======= -->
<section class="auth">
<div class="container">
<div class="row justify-content-center user-auth">
<div class="col-12 col-md-6 col-lg-6 col-sm-10 col-xl-6 ">
<div class="text-center">
@if(Session::has('message'))
<div class="alert alert-danger alert-dismissible fade show" role="alert">
{{ Session::get('message') }}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
</div>
@endif
@if (session('status'))
<div class="alert alert-success alert-dismissible fade show" role="alert">
{{ session('status') }}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
@endif
</div>
<div class="card ">
<h1 class="mt-3 text-center">Password Reset</h1>
<form method="POST" action="{{ route('password.email') }}" class="mt-5 card__form">
{{csrf_field()}}
<div class="form-group ">
@if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
@endif
<small>Forgot your password? No problem. Just let us know your email address and we will email you a password reset link that will allow you to choose a new one.</small> <br>
<input type="email" class="form-control {{ $errors->has('email') ? ' has-error' : '' }}" name ="email" value="{{ old('email') }}" id="email" placeholder="name@example.com" required>
</div>
<div class="form-group">
<button class="mt-4 btn btn-primary" type="submit" >Email Password Reset Link</button>
</div>
<div class="mb-3 text-center">
<small class="mb-2 text-center "> <a href="{{route('login')}}">Repeat Login.</a> </small>
</div>
<div class="text-center">
<hr>
<small class="text-center ">© Copyright {{date('Y')}} {{$settings->site_name}} <br> All Rights Reserved.</small>
</div>
</form>
</div>
</div>
</div>
</div>
</section>
</body>
</html>
尝试使用这个,但它不工作,所以我注解出来:
//Route::get('/forgot-password', function () { return view('auth.forget-password'); })->middleware('guest')->name('password.request');
我还尝试通过添加requestPasswordResetLinkView对fortifyServiceProvider.php进行一些更改,但没有效果
<?php
namespace App\Providers;
use App\Actions\Fortify\CreateNewUser;
use App\Actions\Fortify\ResetUserPassword;
use App\Actions\Fortify\UpdateUserPassword;
use App\Actions\Fortify\UpdateUserProfileInformation;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\ServiceProvider;
use Laravel\Fortify\Fortify;
use App\Models\Settings;
class FortifyServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Fortify::createUsersUsing(CreateNewUser::class);
Fortify::updateUserProfileInformationUsing(UpdateUserProfileInformation::class);
Fortify::updateUserPasswordsUsing(UpdateUserPassword::class);
Fortify::resetUserPasswordsUsing(ResetUserPassword::class);
RateLimiter::for('login', function (Request $request) {
return Limit::perMinute(5)->by($request->email.$request->ip());
});
RateLimiter::for('two-factor', function (Request $request) {
return Limit::perMinute(5)->by($request->session()->get('login.id'));
});
Fortify::requestPasswordResetLinkView(function(){
return view(view: 'auth.forgot-password');
});
Fortify::twoFactorChallengeView(function () {
return view('auth.two-factor-challenge', [
'title' => 'Two Factor Authentication',
'settings' => Settings::where('id','1')->first(),
]);
});
Fortify::confirmPasswordView(function () {
return view('auth.confirm-password', [
'title' => 'Password Confirmation',
'settings' => Settings::where('id','1')->first(),
]);
});
}
}
这是我的博客
<?php
use App\Providers\RouteServiceProvider;
use Laravel\Fortify\Features;
return [
/*
|--------------------------------------------------------------------------
| Fortify Guard
|--------------------------------------------------------------------------
|
| Here you may specify which authentication guard Fortify will use while
| authenticating users. This value should correspond with one of your
| guards that is already present in your "auth" configuration file.
|
*/
'guard' => 'web',
/*
|--------------------------------------------------------------------------
| Fortify Password Broker
|--------------------------------------------------------------------------
|
| Here you may specify which password broker Fortify can use when a user
| is resetting their password. This configured value should match one
| of your password brokers setup in your "auth" configuration file.
|
*/
'passwords' => 'users',
/*
|--------------------------------------------------------------------------
| Username / Email
|--------------------------------------------------------------------------
|
| This value defines which model attribute should be considered as your
| application's "username" field. Typically, this might be the email
| address of the users but you are free to change this value here.
|
| Out of the box, Fortify expects forgot password and reset password
| requests to have a field named 'email'. If the application uses
| another name for the field you may define it below as needed.
|
*/
'username' => 'email',
'email' => 'email',
/*
|--------------------------------------------------------------------------
| Home Path
|--------------------------------------------------------------------------
|
| Here you may configure the path where users will get redirected during
| authentication or password reset when the operations are successful
| and the user is authenticated. You are free to change this value.
|
*/
'home' => RouteServiceProvider::HOME,
/*
|--------------------------------------------------------------------------
| Fortify Routes Prefix / Subdomain
|--------------------------------------------------------------------------
|
| Here you may specify which prefix Fortify will assign to all the routes
| that it registers with the application. If necessary, you may change
| subdomain under which all of the Fortify routes will be available.
|
*/
'prefix' => '',
'domain' => null,
/*
|--------------------------------------------------------------------------
| Fortify Routes Middleware
|--------------------------------------------------------------------------
|
| Here you may specify which middleware Fortify will assign to the routes
| that it registers with the application. If necessary, you may change
| these middleware but typically this provided default is preferred.
|
*/
'middleware' => ['web'],
/*
|--------------------------------------------------------------------------
| Rate Limiting
|--------------------------------------------------------------------------
|
| By default, Fortify will throttle logins to five requests per minute for
| every email and IP address combination. However, if you would like to
| specify a custom rate limiter to call then you may specify it here.
|
*/
'limiters' => [
'login' => 'login',
'two-factor' => 'two-factor',
],
/*
|--------------------------------------------------------------------------
| Register View Routes
|--------------------------------------------------------------------------
|
| Here you may specify if the routes returning views should be disabled as
| you may not need them when building your own application. This may be
| especially true if you're writing a custom single-page application.
|
*/
'views' => true,
/*
|--------------------------------------------------------------------------
| Features
|--------------------------------------------------------------------------
|
| Some of the Fortify features are optional. You may disable the features
| by removing them from this array. You're free to only remove some of
| these features or you can even remove all of these if you need to.
|
*/
'features' => [
Features::registration(),
Features::resetPasswords(),
Features::emailVerification(),
Features::updateProfileInformation(),
Features::updatePasswords(),
Features::twoFactorAuthentication([
'confirmPassword' => true,
]),
],
];
1条答案
按热度按时间nukf8bse1#
lavarel“忘记密码”默认为这个值“password.request”把它放在html的href中:
{{路由(“密码.请求”)}}
应该可以。