我对该项目有两个独立的Auth,一个是医生(登录,注册和重置)[帐户表],另一个是患者(客户)(登录,注册和重置)[患者表]。
每个病人都可以在任何医生(帐户)的同一封邮件中注册。
我已经完成了所有工作,但我的问题是,当患者在特定医生帐户中重设密码时。 Laravel在患者表中更改患者邮件的密码。
我的问题是:如何为resetPassword方法添加条件
例如:其中mail = $ mail和account_id = $ account_id
我成功地通过以下方式覆盖了sendRequestResetLinkMail方法
PatientAuth \ ForgotPasswordController.php:
public function sendResetLinkEmail(Request $request)
{
$this->validate($request, [
'email' => 'required|email',
]);
$response = $this->broker()->sendResetLink([
'email' => $request->input('email'),
'account_id' => Hashids::decode($request->segment(3)),
]);
return $response == Password::RESET_LINK_SENT
? $this->sendResetLinkResponse($response)
: $this->sendResetLinkFailedResponse($request, $response);
}
ResetPasswordController.php:
class ResetPasswordController extends Controller
{
public function __construct()
{
$this->middleware('lang');
}
//Client redirect path
protected function redirectTo(Request $request)
{
return route('WSG.view.home', $request->segments(3));
}
//trait for handling reset Password for patient / client
use ResetsPasswords;
//Show form to patient / client where they can reset password
public function showResetForm(Request $request, $id, $token = null)
{
$id = Hashids::decode($id);
$main_settings = WSGeneratorMainSetting::where('account_id', $id)->first();
return view('doctor_website.layouts.reset',
[
'token' => $token,
'email' => $request->email,
'main_settings' => $main_settings,
]
);
}
protected function credentials(Request $request)
{
return $request->only(
'email', 'password', 'password_confirmation', 'account_id' , 'token'
);
}
//returns Password broker of seller
public function broker()
{
return Password::broker('clients');
}
//returns authentication guard of seller
protected function guard()
{
return Auth::guard('client');
}
}