diff --git a/app/Http/Controllers/Admin/Login.php b/app/Http/Controllers/Admin/Login.php index 29186fdb..93ce6756 100644 --- a/app/Http/Controllers/Admin/Login.php +++ b/app/Http/Controllers/Admin/Login.php @@ -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"; } } diff --git a/app/Http/routes.php b/app/Http/routes.php index 128eb769..c73983a4 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -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'); }); diff --git a/app/Models/User.php b/app/Models/User.php index 33045e15..c539cf36 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -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; @@ -31,5 +32,65 @@ class User extends Model protected $hidden = [ 'password', 'remember_token', ]; - -} \ No newline at end of file + + /** + * 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'; + }} \ No newline at end of file diff --git a/resources/views/admin/loginForm/form.blade.php b/resources/views/admin/loginForm/form.blade.php index ae2bc421..a870c7c7 100644 --- a/resources/views/admin/loginForm/form.blade.php +++ b/resources/views/admin/loginForm/form.blade.php @@ -41,7 +41,7 @@