![](/img/trans.png)
[英]How to change default email reset link for the WordPress reset a password
[英]How to Change Default Reset Password Link in Laravel 5
管理員登錄后,我在 Laravel 5 應用程序中使用更改密碼功能。我使用 laravel 提供的默認表單更改密碼功能,該功能重定向到 /userpasswords/email,當用戶單擊“發送密碼重置”關聯”。 郵件 id 上發送了一封郵件,但我想更改此 url。 我的 url 變成http://localhost/bqs_test/public/index.php/password/reset/1f488a5daf26b57af2d928bb9c0b14e627b34c3459d819f471d402c42f476bf2發送到它的電子郵件 id 為http://localhost/bqs_test/public/index.php/password/1f488a5daf26b57af2d928bb9c0b14e627b34c3459d819f471d402c42f476bf2為http:// localhost /qsbindex/php用戶密碼/重置/1f488a5daf26b57af2d928bb9c0b14e627b34c3459d819f471d402c42f476bf2 。 我該怎么做,我是 Laravel 的新手,所以請有人幫忙。 我的代碼是:
<?php echo Form::open(array('url' => '/userpasswords/email', 'method' => 'post','class'=>'form-horizontal')); ?>
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="form-group">
<label class="col-md-4 control-label">E-Mail Address</label>
<div class="col-md-6">
<input type="email" class="form-control" name="email" value="{{ Auth::user()->email }}" readonly>
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary">
Send Password Reset Link
</button>
</div>
</div>
路由定義為:
Route::controllers([
'auth' => 'Auth\AuthController',
'password' => 'Auth\PasswordController',
'userpasswords' => 'Auth\UserPasswordController'
]);
UserPasswordController 與 PasswordController 相同,但它使用不同的特性 ResetPasswords,它與 ResetsPasswords 相同,但略有變化。 我在 ResetPasswords 中的 postEmail 方法是這樣的:
public function postEmail(Request $request)
{
$this->validate($request, ['email' => 'required|email']);
$response = $this->passwords->sendResetLink($request->only('email'), function($m)
{
$m->subject($this->getEmailSubject());
});
switch ($response)
{
case PasswordBroker::RESET_LINK_SENT:
return redirect()->back()->with('status', trans($response));
case PasswordBroker::INVALID_USER:
return redirect()->back()->withErrors(['email' => trans($response)]);
}
}
有人請幫助我如何更改網址。
您可以編輯或創建此視圖以更改要發送的內容
<!-- resources/views/emails/password.blade.php -->
Click here to reset your password: {{ url('userpasswords/reset/'.$token) }}
為了匹配自動生成的身份驗證路由,網址應為:
{!! url('password/reset/'.$token) !!}
<?php
namespace App\Http\YourControllers;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
class YourControllers extends Controller
{
use SendsPasswordResetEmails;
public function resetPassLink(Request $request)
{
$response = $this->broker()->sendResetLink(['email' => $request->get('email')]);
if ($response) {
return view('...')->with('message', 'We have e-mailed your password reset link!');
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.