public function login(Request $request) {
// auth()->logout();
Auth::logout();
$phone = $request->phone;
$user = User::where('phone', $phone)->first();
if ($user) {
Auth::login($user, true);
return redirect()->route('catalog.index');
}
else {
return redirect()->back();
}
}
Auth::logoutOtherDevices('password');
public function login(Request $request)
{
$phone = $request->phone;
$user = User::where('phone', $phone)->first();
if ($user) {
Auth::login($user, true);
Auth::logoutOtherDevices($request->password);
return redirect()->route('catalog.index');
}
else {
return redirect()->back();
}
}
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';
}
protected $fillable = [
'phone',
'password',
];
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']),
]);
}
\Illuminate\Session\Middleware\AuthenticateSession::class,