From 7046e7ca36c0959184ca6679175e497e2954e769 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Thu, 27 Aug 2020 11:20:50 +0800 Subject: [PATCH] bulk commit --- .../Abstracts/AbstractControllerLogic.php | 1 - .../AuthenticateUserLogic.php | 1 + .../ControllersLogic/CreateUserLogic.php | 1 - .../Services/AuthenticationRedirect.php | 7 +++++-- app/Models/User.php | 5 +++-- .../forms/RegistrationFormComponent.vue | 21 ++++++++++++------- .../sections/LoginSectionComponent.vue | 9 +------- .../CompanyProfileSectionComponent.vue | 2 +- resources/assets/vue/mixins/requestMixin.js | 9 ++------ resources/views/partials/menu.blade.php | 2 +- 10 files changed, 28 insertions(+), 30 deletions(-) diff --git a/app/Classes/General/Abstracts/AbstractControllerLogic.php b/app/Classes/General/Abstracts/AbstractControllerLogic.php index eca73016..4a0366b2 100644 --- a/app/Classes/General/Abstracts/AbstractControllerLogic.php +++ b/app/Classes/General/Abstracts/AbstractControllerLogic.php @@ -52,7 +52,6 @@ abstract class AbstractControllerLogic return $this->logic($request); } catch (ErrorException $exception){ - dd($exception); return (new ApiResponseObject($this->getNotificationTitle().' failed', $exception->getMessage(), $exception->getCode()))->handler(); } diff --git a/app/Classes/Modules/Accounts/ControllersLogic/AuthenticateUserLogic.php b/app/Classes/Modules/Accounts/ControllersLogic/AuthenticateUserLogic.php index a28df296..9785cbc6 100644 --- a/app/Classes/Modules/Accounts/ControllersLogic/AuthenticateUserLogic.php +++ b/app/Classes/Modules/Accounts/ControllersLogic/AuthenticateUserLogic.php @@ -60,6 +60,7 @@ class AuthenticateUserLogic extends AbstractControllerLogic return $this->response(['access_token' => $token, 'redirect_url' => $this->authenticationRedirect->url()]); } catch (\Exception $exception){ + dd($exception); throw new ErrorException($exception->getMessage(), $exception->getCode()); } diff --git a/app/Classes/Modules/Accounts/ControllersLogic/CreateUserLogic.php b/app/Classes/Modules/Accounts/ControllersLogic/CreateUserLogic.php index d988fe08..7bce7f7e 100644 --- a/app/Classes/Modules/Accounts/ControllersLogic/CreateUserLogic.php +++ b/app/Classes/Modules/Accounts/ControllersLogic/CreateUserLogic.php @@ -121,7 +121,6 @@ class CreateUserLogic extends AbstractControllerLogic return $this->authenticateUserLogic->execute($request); } catch (\Exception $exception){ - dd($exception); throw new ErrorException($exception->getMessage(), $exception->getCode()); } } diff --git a/app/Classes/Modules/Accounts/Services/AuthenticationRedirect.php b/app/Classes/Modules/Accounts/Services/AuthenticationRedirect.php index 2fce8fd6..1dbc05d2 100644 --- a/app/Classes/Modules/Accounts/Services/AuthenticationRedirect.php +++ b/app/Classes/Modules/Accounts/Services/AuthenticationRedirect.php @@ -9,10 +9,13 @@ class AuthenticationRedirect { public function url(){ - $userRole = (int) Auth()->user()->role_id; - return $userRole === Roles::ADMIN || $userRole === Roles::SUPER_ADMIN ? route('company.profile', ['id' => 10]) : route('company.profile', ['id' => 1]); + if($userRole === Roles::ADMIN){ + return route('admin.dashboard'); + } + + return route('company.profile', ['id' => Auth()->user()->employers->first()->company->id]); } diff --git a/app/Models/User.php b/app/Models/User.php index ec6b5d71..955bcc08 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -2,6 +2,7 @@ namespace App\Models; +use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasMany; use Tymon\JWTAuth\Contracts\JWTSubject; use Illuminate\Notifications\Notifiable; @@ -49,8 +50,8 @@ class User extends AbstractModel implements return $this->hasMany(PasswordReset::class, 'user_id', 'id'); } - public function employers(): hasMany { - return $this->hasMany(CompanyModule::class); + public function employers(): belongsToMany { + return $this->belongsToMany(CompanyModule::class, (new CompanyEmployee())->getTable(), 'user_id', 'module_id'); } diff --git a/resources/assets/vue/components/authentication/forms/RegistrationFormComponent.vue b/resources/assets/vue/components/authentication/forms/RegistrationFormComponent.vue index 6ad03c18..7cabc5cd 100644 --- a/resources/assets/vue/components/authentication/forms/RegistrationFormComponent.vue +++ b/resources/assets/vue/components/authentication/forms/RegistrationFormComponent.vue @@ -174,15 +174,15 @@
-
+
- - + +
@@ -192,8 +192,8 @@
@@ -236,7 +236,7 @@ phone: {}, wechat: {}, password: {}, - confirmPassword: {} + confirm_password: {} } : { @@ -248,7 +248,7 @@ phone: { required }, wechat: {}, password: { required }, - confirmPassword: { sameAsPassword: sameAs('password') } + confirm_password: { sameAsPassword: sameAs('password') } } } }, @@ -285,7 +285,14 @@ } }, successHandler(response){ + localStorage.setItem('user-token', response.payload.access_token); + this.$store.dispatch('userAuthentication', {access_token: response.payload.access_token}); + this.error = ''; + this.$store.dispatch('toggleSection', {name: 'loginSuccess', status: true}) + setTimeout(function(){ + window.location.href = response.payload.redirect_url; + }, 2000); }, errorHandler(error){ diff --git a/resources/assets/vue/components/authentication/sections/LoginSectionComponent.vue b/resources/assets/vue/components/authentication/sections/LoginSectionComponent.vue index ce5fc0bf..bda6d6a2 100644 --- a/resources/assets/vue/components/authentication/sections/LoginSectionComponent.vue +++ b/resources/assets/vue/components/authentication/sections/LoginSectionComponent.vue @@ -68,13 +68,6 @@
Create Account
-
-
1
-
- -
-
2
-
@@ -83,7 +76,7 @@
- +
diff --git a/resources/assets/vue/components/company/sections/CompanyProfileSectionComponent.vue b/resources/assets/vue/components/company/sections/CompanyProfileSectionComponent.vue index 122be025..91d754c1 100644 --- a/resources/assets/vue/components/company/sections/CompanyProfileSectionComponent.vue +++ b/resources/assets/vue/components/company/sections/CompanyProfileSectionComponent.vue @@ -46,7 +46,7 @@ -
+
diff --git a/resources/assets/vue/mixins/requestMixin.js b/resources/assets/vue/mixins/requestMixin.js index a10ed973..d402a2d6 100644 --- a/resources/assets/vue/mixins/requestMixin.js +++ b/resources/assets/vue/mixins/requestMixin.js @@ -8,16 +8,12 @@ export default { method: method, parameters: this.parameters }).then(response => { - let success = response.ok, - statusCode = response.status; + let success = response.ok; + response.json().then(response => { if(!success){ - // if(statusCode === 401 && url !== route('api.account.authenticate')){ - // window.location.href = route('authenticate.expire'); - // } - errorNotification ? this.$store.dispatch('createNotification', {title: response.title, message: response.message, type: 'error'}): null; this.errorHandler(response); return; } @@ -36,7 +32,6 @@ export default { }, validate() { if(this.$v){ - console.log(this.$v.$invalid); this.$v.$touch(); return !this.$v.$invalid; } diff --git a/resources/views/partials/menu.blade.php b/resources/views/partials/menu.blade.php index 0965933c..076a5a14 100644 --- a/resources/views/partials/menu.blade.php +++ b/resources/views/partials/menu.blade.php @@ -1,6 +1,6 @@
-