這是 laravel 中的用戶注冊自定義表單。public function register(RegisterTalentRequest $request) { $talent = $this->create($request->except('_method', '_token')); //up till here the registration values are successfully saved in the //database table, but it's not logged in following the below code //and is directing to the custom login page. Auth::attempt(['email' => $request->email, 'password' => $request->password]); return redirect()->route('dashboard'); //directing to login and not dashboard}
2 回答
慕田峪9158850
TA貢獻1794條經(jīng)驗 獲得超8個贊
默認(rèn)情況下,Auth外觀(或auth()輔助函數(shù))將使用文件guard中的默認(rèn)設(shè)置config/auth.php。
如果您想在登錄或注冊方法中使用不同的保護,您需要顯式設(shè)置它:
Auth::guard('guard-name')->attempt(...);或者,當(dāng)使用authorguest中間件時,您可以傳遞您想要使用的保護,例如 (auth:guard-name或guest:guard-name) 這會將默認(rèn)保護設(shè)置guard-name為請求的其余部分,因此您不需要顯式設(shè)置它。
- 2 回答
- 0 關(guān)注
- 172 瀏覽
添加回答
舉報
0/150
提交
取消
