如何在 Laravel 5 中更改默认重置密码链接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32921784/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to Change Default Reset Password Link in Laravel 5
提问by M.J
I am using a change password functionality in my Laravel 5 Application after the Admin has logged in. I am using the default form provided by laravel for change password functionality which redirects to /userpasswords/email, When the user click on the "Send Password Reset Link". A mail is sent on the mail id but I want to change this url. My url becomes http://localhost/bqs_test/public/index.php/password/reset/1f488a5daf26b57af2d928bb9c0b14e627b34c3459d819f471d402c42f476bf2which is sent on the email id but I want it to be as http://localhost/bqs_test/public/index.php/userpasswords/reset/1f488a5daf26b57af2d928bb9c0b14e627b34c3459d819f471d402c42f476bf2. How can I do this, I am new to Laravel, so please someone help. My code is as:
管理员登录后,我在 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/reset/1f488a5daf26b57af2d928bb9c0b14e627b34c3459d819f471d402c42f476bf2是http://localhost /bqs_test /用户密码/重置/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>
The route defined as:
路由定义为:
Route::controllers([
'auth' => 'Auth\AuthController',
'password' => 'Auth\PasswordController',
'userpasswords' => 'Auth\UserPasswordController'
]);
]);
The UserPasswordController is same as PasswordController but it uses a different trait ResetPasswords which is same as ResetsPasswords with slight change. My postEmail method in ResetPasswords is like:
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)]);
}
}
Someone please help how can I change the Url.
有人请帮助我如何更改网址。
回答by Hanlin Wang
you can edit or create this view to change what you want to send
您可以编辑或创建此视图以更改要发送的内容
<!-- resources/views/emails/password.blade.php -->
Click here to reset your password: {{ url('userpasswords/reset/'.$token) }}
回答by vijay kanaujia
<?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!');
}
}
}