allow login via username

This commit is contained in:
1day2die 2023-01-10 19:12:07 +01:00
parent 9e8337efcb
commit 16a48cd2aa
2 changed files with 15 additions and 2 deletions

View file

@ -41,6 +41,19 @@ class LoginController extends Controller
$this->middleware('guest')->except('logout');
}
/**
* Get the login username to be used by the controller.
*
* @return string
*/
public function username()
{
$login = request()->input('email');
$field = filter_var($login, FILTER_VALIDATE_EMAIL) ? 'email' : 'name';
request()->merge([$field => $login]);
return $field;
}
public function login(Request $request)
{
$validationRules = [

View file

@ -31,9 +31,9 @@
<div class="form-group">
<div class="input-group mb-3">
<input type="email" name="email"
<input type="text" name="email"
class="form-control @error('email') is-invalid @enderror"
placeholder="{{ __('Email') }}">
placeholder="{{ __('Email or Username') }}">
<div class="input-group-append">
<div class="input-group-text">
<span class="fas fa-envelope"></span>