FEATURE #1358: add interface Authenticable to User model.
It seems that Laravel needs User models (users which are about to authenticate) to implement Authenticable interface.
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Admin;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
/**
|
||||
* Class Login
|
||||
@@ -15,22 +16,23 @@ use Illuminate\Http\Request;
|
||||
*/
|
||||
class Login extends Controller
|
||||
{
|
||||
/**
|
||||
* @param array $data
|
||||
*/
|
||||
protected function validator(array $data)
|
||||
{
|
||||
return Validator::make($data, [
|
||||
'name' => 'required|max:255',
|
||||
'email' => 'required|email|max:255|unique:users',
|
||||
'password' => 'required|confirmed|min:6',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
*/
|
||||
public function postLogin(Request $request)
|
||||
{
|
||||
if (Auth::check()) {
|
||||
echo "uz jsem prihlasen.";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (Auth::attempt(['email' => $request->email, 'password' => $request->password])) {
|
||||
echo "prihlaseni uspesne";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
echo "neplatne prihlaseni";
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ Route::group(['middleware' => ['web']], function () {
|
||||
});
|
||||
|
||||
// POST methods
|
||||
Route::post('admin/login', 'Admin\Login@postLogin')
|
||||
Route::post('login', 'Admin\Login@postLogin')
|
||||
->name('login');
|
||||
});
|
||||
|
||||
|
||||
+62
-1
@@ -2,12 +2,13 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class User
|
||||
*/
|
||||
class User extends Model
|
||||
class User extends Model implements Authenticatable
|
||||
{
|
||||
|
||||
public $timestamps = false;
|
||||
@@ -32,4 +33,64 @@ class User extends Model
|
||||
'password', 'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the name of the unique identifier for the user.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthIdentifierName()
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the unique identifier for the user.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAuthIdentifier()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the password for the user.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthPassword()
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the token value for the "remember me" session.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRememberToken()
|
||||
{
|
||||
return $this->remember_token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the token value for the "remember me" session.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setRememberToken($value)
|
||||
{
|
||||
$this->remember_token = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the column name for the "remember me" token.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRememberTokenName()
|
||||
{
|
||||
return 'remember_token';
|
||||
}}
|
||||
@@ -41,7 +41,7 @@
|
||||
</label>
|
||||
|
||||
<p>
|
||||
<a type="submit" class="button expanded">@lang('admin/loginForm.login')</a>
|
||||
<button type="submit" class="button expanded">@lang('admin/loginForm.login')</button>
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user