Closed ashkan90 closed 5 years ago
I'm trying to log in with username instead of email.
This package uses email by default as 'username'.
You can override the username()
to achieve the desired behavior.
I already write it.
public function username()
{
return "username";
}
it's not working even in this case :(
Override the username()
in app/Http/Controllers/Teacher/Auth/LoginController.php
.
/**
* {@inheritdoc}
*/
public function username()
{
- return 'email';
+ return 'name';
}
Also, update the view (.../resources/views/teacher/auth/login.blade.php
) to send name
instead of email
.
- <div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
+ <div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
- <label for="email" class="col-md-4 control-label">E-Mail Address</label>
+ <label for="name" class="col-md-4 control-label">Username</label>
<div class="col-md-6">
- <input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required autofocus>
+ <input id="name" type="text" class="form-control" name="name" value="{{ old('name') }}" required autofocus>
- @if ($errors->has('email'))
+ @if ($errors->has('name'))
<span class="help-block">
- <strong>{{ $errors->first('email') }}</strong>
+ <strong>{{ $errors->first('name') }}</strong>
</span>
@endif
</div>
</div>
Hi, I cannot loginto other guarded model. When i log out and go back for log in again and bom. Credentials don't match. But register work like a boss << I'm trying to log in with username instead of email. <<