我有这段代码:
/password/email
似乎它什么也没做。
当我查看firebug时,我收到一个包含{{1}}页面html的html页面。
我猜我需要修改发送密码重置链接的工作原理。
有人可以帮我解决这个问题。
非常感谢您的帮助!
谢谢!
答案 0 :(得分:5)
好的,我通过把它放在我的PasswordController.php
上设法解决了这个问题public function getEmail(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[
'error'=>'false',
'msg'=>'A password link has been sent to your email address'
];
case PasswordBroker::INVALID_USER:
return[
'error'=>'true',
'msg'=>"We can't find a user with that email address"
];
}
}
我不确定这是否有效但这对我有用。希望这有助于某人。
谢谢!
答案 1 :(得分:2)
如果您想自定义或更改通过POST
发送的AJAX
网址,请在此处填写完整的答案:
jQuery.ajax({
type:"POST",
url:"/user/password/reset",
data:{
_token: jQuery("#forgotPasswordContainer input[name='_token']").val(),
email: email
},
dataType:'json',
beforeSend:function(){
},
success:function(data){
},
complete:function(){
}
});
Route::post('user/password/reset', [
'uses' => 'Controller_name@index'
]);
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use Illuminate\Contracts\Auth\PasswordBroker;
class Controller_name extends Controller
{
public function index(Request $request, PasswordBroker $passwords)
{
if( $request->ajax() )
{
$this->validate($request, ['email' => 'required|email']);
$response = $passwords->sendResetLink($request->only('email'));
switch ($response)
{
case PasswordBroker::RESET_LINK_SENT:
return[
'error'=>'false',
'msg'=>'A password link has been sent to your email address'
];
case PasswordBroker::INVALID_USER:
return[
'error'=>'true',
'msg'=>"We can't find a user with that email address"
];
}
}
return false;
}
}
为电子邮件模板创建新目录auth > emails > password.blade.php
:
Click here to reset your password .<br />
<a target="_blank" href="{{ url('password/reset', $token).'?email='.urlencode($user->getEmailForPasswordReset()) }}">Click to Reset Password</a>