Skip to content

Instantly share code, notes, and snippets.

@madindo
Created September 29, 2022 01:40
Show Gist options
  • Save madindo/3a0f74b79c69c3886ed856fb017e9adc to your computer and use it in GitHub Desktop.
Save madindo/3a0f74b79c69c3886ed856fb017e9adc to your computer and use it in GitHub Desktop.
Laravel 8 with breeze - login using phone number
$path = storage_path() . "/json/phone_country.json";
$phone_country = json_decode(file_get_contents($path), true);
$phone = '';
foreach ($phone_country as $country) {
$pos = strpos($this->email, $country['dial_code']);
if ($pos !== false) {
$phone = str_replace($country['dial_code'],'', $this->email);
}
}
if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) {
if (! Auth::attempt(array('phone' => $phone, 'password' => $this->password))) {
RateLimiter::hit($this->throttleKey());
throw ValidationException::withMessages([
'email' => __('auth.failed'),
]);
}
RateLimiter::hit($this->throttleKey());
throw ValidationException::withMessages([
'email' => __('auth.failed'),
]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment