LoginController
public function login(Request $request) {
$phone = $request->password;
$user = User::where('phone', $phone)->first();
if ($user) {
Auth::login($user, true);
Auth::logoutOtherDevices($phone, 'password');
return redirect()->route('catalog.index');
}
else {
return redirect()->back();
}
}
public function username() {
return 'phone';
}
User.php
protected $fillable = [
'phone',
'password',
];
RegisterController:
protected function validator(array $data)
{
return Validator::make($data, [
'password' => ['required', 'regex:/((8|\+7)-?)?\(?\d{3,5}\)?-?\d{1}-?\d{1}-?\d{1}-?\d{1}-?\d{1}((-?\d{1})?-?\d{1})?/'],
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\Models\User
*/
protected function create(array $data)
{
return User::create([
'phone' => $data['password'],
'password' => Hash::make($data['password']),
]);
}
+ в Kernel.php расскоментировал строку:
\Illuminate\Session\Middleware\AuthenticateSession::class,