From 893f29849e14fc7ca258bd875e58e61638e4b36a Mon Sep 17 00:00:00 2001 From: Bubka <858858+Bubka@users.noreply.github.com> Date: Tue, 24 Nov 2020 23:08:21 +0100 Subject: [PATCH] Refactor checkUser controller --- app/Http/Controllers/Auth/RegisterController.php | 9 +-------- resources/js/views/auth/Login.vue | 11 ++++------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 9296398c..e0bfcc71 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -33,16 +33,9 @@ class RegisterController extends Controller */ public function checkUser() { - - $count = DB::table('users')->count(); $username = DB::table('users')->where('id', 1)->value('name'); - if( $count === 1 ) { - return response()->json(['userCount' => $count, 'username' => $username], 200); - } - else { - return response()->json(['userCount' => $count], 200); - } + return response()->json(['username' => $username], 200); } /** diff --git a/resources/js/views/auth/Login.vue b/resources/js/views/auth/Login.vue index 3a421b82..5bb0784b 100644 --- a/resources/js/views/auth/Login.vue +++ b/resources/js/views/auth/Login.vue @@ -1,12 +1,12 @@ @@ -18,9 +18,7 @@ export default { data(){ return { - - userCount: null, - username: '', + username: null, isDemo: this.$root.appSettings.isDemoApp, form: new Form({ email: '', @@ -70,11 +68,10 @@ next(async vm => { const { data } = await vm.axios.post('api/checkuser') - if( data.userCount === 0 ) { + if( !data.username ) { return next({ name: 'register' }); } else { - vm.userCount = data.userCount vm.username = data.username } });