S
S
Sergey Zavialov2019-04-03 14:11:45
Laravel
Sergey Zavialov, 2019-04-03 14:11:45

How to change the field by which authorization will occur?

Changed email to login in lodin.blade file

<div class="form-group row">
              <label for="login" class="col-md-4 col-form-label text-md-right">{{ __(' login') }}</label>
                    <div class="col-md-6">
                         <input id="login" type="text" class="form-control{{ $errors->has('login') ? ' is-invalid' : '' }}" name="login" value="{{ old('login') }}" required autofocus>

                           @if ($errors->has('login'))
                               <span class="invalid-feedback" role="alert">
                               <strong>{{ $errors->first('login') }}</strong>
                               </span>
                            @endif
                      </div>
          </div>

But authorization does not occur. The entered login itself is not saved, it is reset.
Where else to change the code besides the view?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
Crash XD, 2019-04-03
@crashxd

Redefine the function in the LoginController file:

public function username()
{
    return 'login';
}

S
Sergey Zavyalov, 2019-04-03
@SZV

I changed the function in the AuthenticatesUsers file, you can access this file by following the chain from LoginController, it contains a link to this file.
did this:
public function username()
{
return 'login';
}
Found still the second method. If anyone is interested. Although the first method works and was originally provided by laravel developers, it is really clumsily done in the sense that the function was not located immediately after the login function, so that it would be more clear why it exists.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question