From ec26dd145de46a241a26d876ae676344543ebfb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Drunen?= Date: Sun, 13 Aug 2023 02:55:23 +0200 Subject: [PATCH] Create barebones sequence for logging in --- app/Http/Controllers/Api/LogInController.php | 38 +++++++++++++++++++ resources/assets/js/prototype/app.js | 5 +++ .../assets/js/prototype/screens/Dashboard.vue | 11 ++++++ .../assets/js/prototype/screens/Login.vue | 33 ++++++++++++++-- routes/api.php | 5 ++- 5 files changed, 86 insertions(+), 6 deletions(-) create mode 100644 app/Http/Controllers/Api/LogInController.php create mode 100644 resources/assets/js/prototype/screens/Dashboard.vue diff --git a/app/Http/Controllers/Api/LogInController.php b/app/Http/Controllers/Api/LogInController.php new file mode 100644 index 00000000..2afb3f49 --- /dev/null +++ b/app/Http/Controllers/Api/LogInController.php @@ -0,0 +1,38 @@ +validate([ + 'email' => ['required'], + 'password' => ['required'], + ]); + + if ( + Auth::attempt([ + 'email' => $request->input('email'), + 'password' => $request->input('password'), + ]) + ) { + // LOG ATTEMPT? + + return response() + ->json([ + 'token' => 'TOKEN_GOES_HERE', + ]); + } else { + // LOG ATTEMPT? + + return response() + ->json(['error' => 'UNABLE_TO_LOG_IN']); + } + } +} diff --git a/resources/assets/js/prototype/app.js b/resources/assets/js/prototype/app.js index 9d60f8cd..f2e982e8 100644 --- a/resources/assets/js/prototype/app.js +++ b/resources/assets/js/prototype/app.js @@ -4,6 +4,7 @@ import VueRouter from 'vue-router'; import App from './components/App.vue'; import Login from './screens/Login.vue'; +import Dashboard from './screens/Dashboard.vue'; Vue.use(VueRouter); @@ -12,6 +13,10 @@ const routes = [ path: '/prototype/login', name: 'login', component: Login, + }, { + path: '/prototype/dashboard', + name: 'dashboard', + component: Dashboard, }, ]; diff --git a/resources/assets/js/prototype/screens/Dashboard.vue b/resources/assets/js/prototype/screens/Dashboard.vue new file mode 100644 index 00000000..4c14c6f3 --- /dev/null +++ b/resources/assets/js/prototype/screens/Dashboard.vue @@ -0,0 +1,11 @@ + + + diff --git a/resources/assets/js/prototype/screens/Login.vue b/resources/assets/js/prototype/screens/Login.vue index 0c56170e..0d63e077 100644 --- a/resources/assets/js/prototype/screens/Login.vue +++ b/resources/assets/js/prototype/screens/Login.vue @@ -1,5 +1,30 @@ diff --git a/routes/api.php b/routes/api.php index 8e54864d..3b963692 100644 --- a/routes/api.php +++ b/routes/api.php @@ -1,5 +1,6 @@