Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow customizing field to use with login procedure #1318

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config/adminlte.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
'usermenu_image' => false,
'usermenu_desc' => false,
'usermenu_profile_url' => false,

/*
|--------------------------------------------------------------------------
| Layout
Expand Down Expand Up @@ -265,7 +265,7 @@
'password_email_url' => 'password/email',
'profile_url' => false,
'disable_darkmode_routes' => false,

'username_field' => 'email', // This to use it inside LoginController username() return Config('adminlte.usernamefield')
/*
|--------------------------------------------------------------------------
| Laravel Asset Bundling
Expand Down
7 changes: 4 additions & 3 deletions resources/views/auth/login.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

@php( $login_url = View::getSection('login_url') ?? config('adminlte.login_url', 'login') )
@php( $register_url = View::getSection('register_url') ?? config('adminlte.register_url', 'register') )
@php( $username = config('adminlte.username_field', 'email') )
@php( $password_reset_url = View::getSection('password_reset_url') ?? config('adminlte.password_reset_url', 'password/reset') )

@if (config('adminlte.use_route_url', false))
Expand All @@ -26,16 +27,16 @@

{{-- Email field --}}
<div class="input-group mb-3">
<input type="email" name="email" class="form-control @error('email') is-invalid @enderror"
value="{{ old('email') }}" placeholder="{{ __('adminlte::adminlte.email') }}" autofocus>
<input type="{{ $username }}" name="{{ $username }}" class="form-control @error($username) is-invalid @enderror"
value="{{ old($username) }}" placeholder="{{ __('adminlte::adminlte.username') }}" autofocus>
Comment on lines +30 to +31
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes introduces some bugs, first only a set of possible values are accepted by the input type attribute, so it can not be anything, note $username variable may hold any string name. Second, the translation entry __('adminlte::adminlte.username') does not currently exists.


<div class="input-group-append">
<div class="input-group-text">
<span class="fas fa-envelope {{ config('adminlte.classes_auth_icon', '') }}"></span>
</div>
</div>

@error('email')
@error($username)
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
Expand Down