diff --git a/app/Http/Controllers/Admin/Dashboard.php b/app/Http/Controllers/Admin/Dashboard.php index 658158d1..9c09ce42 100644 --- a/app/Http/Controllers/Admin/Dashboard.php +++ b/app/Http/Controllers/Admin/Dashboard.php @@ -4,10 +4,11 @@ namespace App\Http\Controllers\Admin; use Illuminate\Http\Request; use App\Http\Requests; +use Illuminate\Support\Facades\Session; class Dashboard extends Controller { - public function getIndex() { + public function getIndex(Request $request) { return view('admin.dashboard'); } } diff --git a/app/Http/Controllers/Admin/Login.php b/app/Http/Controllers/Admin/Login.php index 7f2697f3..e2e945e2 100644 --- a/app/Http/Controllers/Admin/Login.php +++ b/app/Http/Controllers/Admin/Login.php @@ -6,8 +6,10 @@ use App\Http\Controllers\Controller; use App\Http\Requests; use App\Http\Requests\LoginRequest; use App\Models\User; +use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Hash; +use Illuminate\Support\Facades\Session; /** * Class Login @@ -18,22 +20,6 @@ use Illuminate\Support\Facades\Hash; */ class Login extends Controller { - /** - * Display login form - * - * This method displays login form, or in case that user is logged in, redirects him to admin dashboard panel. - * - * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\View\View - */ - public function getLoginForm() - { - if (Auth::check()) { - return redirect()->route('admin.dashboard'); - } - - return view('admin.loginForm.form'); - } - /** * Login handler * @@ -59,13 +45,9 @@ class Login extends Controller if (Hash::check($request->password, $user->password)) { Auth::login($user); - return redirect()->route('admin.dashboard'); + return redirect()->intended(route('admin.dashboard')); } - // if (Auth::attempt($request->only('email', 'password'))) { - // return redirect()->route('admin.dashboard'); - // } - // login invalid, redirect and inform the user return $this->loginFailed(); } @@ -74,6 +56,7 @@ class Login extends Controller { return redirect() ->route('login') - ->with('error', trans('auth.failed')); + ->with('error', trans('auth.failed')) + ->withInput(); } } diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index f0d8083c..b7665925 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -45,7 +45,7 @@ class Kernel extends HttpKernel */ protected $routeMiddleware = [ 'auth' => \App\Http\Middleware\Authenticate::class, - 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, +// 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, ]; diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index 074f8f9d..45b3d3d7 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -10,19 +10,20 @@ class Authenticate /** * Handle an incoming request. * - * @param \Illuminate\Http\Request $request - * @param \Closure $next - * @param string|null $guard + * @param \Illuminate\Http\Request $request + * @param \Closure $next + * @param string|null $guard + * * @return mixed */ public function handle($request, Closure $next, $guard = null) { - if (!Auth::check($guard)) { + if (!Auth::guard($guard)->check()) { if ($request->ajax()) { return response('Unauthorized.', 401); } - return redirect()->guest('login'); + return redirect()->route('login'); } return $next($request); diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index e27860e2..4cfb9e88 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -18,7 +18,7 @@ class RedirectIfAuthenticated public function handle($request, Closure $next, $guard = null) { if (Auth::guard($guard)->check()) { - return redirect('/'); + return redirect()->route('admin.dashboard'); } return $next($request); diff --git a/app/Http/Requests/LoginRequest.php b/app/Http/Requests/LoginRequest.php index fbb2e9ce..e11198c8 100644 --- a/app/Http/Requests/LoginRequest.php +++ b/app/Http/Requests/LoginRequest.php @@ -4,16 +4,6 @@ namespace App\Http\Requests; class LoginRequest extends Request { - /** - * Determine if the user is authorized to make this request. - * - * @return bool - */ - public function authorize() - { - return true; - } - /** * Get the validation rules that apply to the request. * diff --git a/app/Http/routes.php b/app/Http/routes.php index e28134fb..5209ec7e 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -3,14 +3,18 @@ /** * This routing groups is used for routing along public part of website */ +use Illuminate\Http\Request; + Route::group(['middleware' => ['web']], function () { // display login form - Route::get('login', 'Admin\Login@getLoginForm') + Route::get('login', function () { + return view('admin.loginForm.form'); + }) ->name('loginForm'); // handle login - Route::post('admin/login', 'Admin\Login@postLogin') + Route::post('login', 'Admin\Login@postLogin') ->name('login'); }); @@ -20,7 +24,7 @@ Route::group(['middleware' => ['web']], function () { * This route group serves to handle request in admin */ Route::group([ - 'middleware' => ['auth'], + 'middleware' => ['web', 'auth'], 'namespace' => 'Admin', 'prefix' => 'admin' ], function () { diff --git a/app/Models/User.php b/app/Models/User.php index 9a34c241..0270bc30 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -13,7 +13,7 @@ use Illuminate\Foundation\Auth\Access\Authorizable; */ class User extends Model implements AuthenticableInterface { - use Authenticatable, Authorizable, CanResetPassword; + use Authenticatable, Authorizable; public $timestamps = false; protected $fillable = [ @@ -39,20 +39,4 @@ class User extends Model implements AuthenticableInterface const ROLE_VISITOR = 'visitor'; const ROLE_EDITOR = 'editor'; const ROLE_ADMIN = 'admin'; - - /** - * Validation method for input data - * - * @param array $data - * - * @throws ValidationException - */ - public static function validate(array $data) - { - $valid = true; - - if (!$valid) { - throw new ValidationException(Validator::class, 'Invalid request'); - } - } -} + } diff --git a/composer.json b/composer.json index 00957e95..8d931f25 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,8 @@ { - "name": "laravel/laravel", - "description": "The Laravel Framework.", + "name": "binarity/minicms", + "description": "Content management system.", "keywords": [ - "framework", - "laravel" + "cms" ], "license": "MIT", "type": "project", diff --git a/composer.lock b/composer.lock index 28ee49cf..b6c135db 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "e1df7a663824f03abec6a4688a30e0d3", - "content-hash": "f6d1dca260e16530b88c6572ad98598e", + "hash": "53113db66c2d51264c2a77f87dd0e86b", + "content-hash": "d8baefcd2e40fe5a3b7f262146c46f34", "packages": [ { "name": "classpreloader/classpreloader", @@ -793,16 +793,16 @@ }, { "name": "laravel/framework", - "version": "v5.2.10", + "version": "v5.2.11", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "93dc5b0089eef468157fd7200e575c3861ec59a5" + "reference": "e8ad411ac3ca63f532952417156e32d010fcc522" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/93dc5b0089eef468157fd7200e575c3861ec59a5", - "reference": "93dc5b0089eef468157fd7200e575c3861ec59a5", + "url": "https://api.github.com/repos/laravel/framework/zipball/e8ad411ac3ca63f532952417156e32d010fcc522", + "reference": "e8ad411ac3ca63f532952417156e32d010fcc522", "shasum": "" }, "require": { @@ -917,20 +917,20 @@ "framework", "laravel" ], - "time": "2016-01-13 20:29:10" + "time": "2016-01-22 18:36:05" }, { "name": "laravelcollective/html", - "version": "v5.2.2", + "version": "v5.2.3", "source": { "type": "git", "url": "https://github.com/LaravelCollective/html.git", - "reference": "c88b2d59a56ed2290fc5082a1a6099e357c9fdbc" + "reference": "7ec0ca55cab54cc6d331007d86ec068b61f46aad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/LaravelCollective/html/zipball/c88b2d59a56ed2290fc5082a1a6099e357c9fdbc", - "reference": "c88b2d59a56ed2290fc5082a1a6099e357c9fdbc", + "url": "https://api.github.com/repos/LaravelCollective/html/zipball/7ec0ca55cab54cc6d331007d86ec068b61f46aad", + "reference": "7ec0ca55cab54cc6d331007d86ec068b61f46aad", "shasum": "" }, "require": { @@ -971,7 +971,7 @@ ], "description": "HTML and Form Builders for the Laravel Framework", "homepage": "http://laravelcollective.com", - "time": "2016-01-16 16:54:49" + "time": "2016-01-20 18:28:21" }, { "name": "league/flysystem", diff --git a/resources/views/admin/loginForm/form.blade.php b/resources/views/admin/loginForm/form.blade.php index 543e69fd..214b16f9 100644 --- a/resources/views/admin/loginForm/form.blade.php +++ b/resources/views/admin/loginForm/form.blade.php @@ -4,11 +4,9 @@ - @yield('head_meta') @lang('admin/loginForm.login') | {{$vendorName}} - @yield('head_stylesheets') @@ -29,7 +27,7 @@