diff options
author | Mateja <mail@matejamaric.com> | 2020-10-28 00:19:52 +0100 |
---|---|---|
committer | Mateja <mail@matejamaric.com> | 2020-10-28 00:19:52 +0100 |
commit | 806b02418b9ee53039de96baf9cfcca1c6fa9257 (patch) | |
tree | 1ce01e02f33bd1e6349f7e4a9a9d168f683496bc /app/Http/Controllers | |
parent | a3d432a6a0710261149fdaecdc2a5a62a82fe303 (diff) | |
download | yota-laravel-806b02418b9ee53039de96baf9cfcca1c6fa9257.tar.gz yota-laravel-806b02418b9ee53039de96baf9cfcca1c6fa9257.zip |
Authentication implemented.
Diffstat (limited to 'app/Http/Controllers')
-rw-r--r-- | app/Http/Controllers/PagesController.php | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/app/Http/Controllers/PagesController.php b/app/Http/Controllers/PagesController.php index 5041f05..f42ae3e 100644 --- a/app/Http/Controllers/PagesController.php +++ b/app/Http/Controllers/PagesController.php @@ -9,6 +9,7 @@ use function redirect; use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Redirect; +use Illuminate\Support\Facades\Auth; class PagesController extends Controller { @@ -40,6 +41,12 @@ class PagesController extends Controller return view('pages.login'); } + public function logout(Request $request) + { + Auth::logout(); + return Redirect::back(); + } + public function activities(Request $request) { return view('pages.activities'); @@ -84,7 +91,6 @@ class PagesController extends Controller $validator = Validator::make($request->all(), $rules, $messages); if ($validator->fails()) { - //return redirect('login') return Redirect::back() ->withErrors($validator) ->withInput(); @@ -95,7 +101,11 @@ class PagesController extends Controller //'password' => 'required', //]); //return redirect('login')->with('status', 'Submitted.'); - return Redirect::back()->with('status', 'Submitted.'); + //return Redirect::back()->with('status', 'Submitted.'); + if (Auth::attempt($request->only('email', 'password'))) + return redirect()->intended(route('home')); + else return Redirect::back() + ->withErrors(['failed' => ['Bad credentials!']]); } |