diff --git a/app/Classes/Modules/Accounts/ControllersLogic/UpdateUserLogic.php b/app/Classes/Modules/Accounts/ControllersLogic/UpdateUserLogic.php new file mode 100644 index 00000000..7dbfca9e --- /dev/null +++ b/app/Classes/Modules/Accounts/ControllersLogic/UpdateUserLogic.php @@ -0,0 +1,78 @@ + 'Updated User Profile', + 'message' => 'You have successfully updated the User Profile' + ]; + } + + /** @var CanUpdateUser */ + private $canUpdateUser; + + /** @var UpdatesUser */ + private $updatesUser; + + /** @var FetchesUser */ + private $fetchesUser; + + /** + * UpdateAddressLogic constructor. + * @param CanUpdateUser $canUpdateUser + * @param UpdatesUser $updatesUser + * @param FetchesUser $fetchesUSer + */ + public function __construct(CanUpdateUser $canUpdateUser, UpdatesUser $updatesUser, FetchesUser $fetchesUser) + { + $this->canUpdateUser = $canUpdateUser; + $this->updatesUser = $updatesUser; + $this->fetchesUser = $fetchesUser; + } + + + /** + * @param Request $request + * @return JsonResponse + * @throws ErrorException + */ + public function logic(Request $request) : JsonResponse + { + try { + + $object = new UserObject($request->input('name')); + + $this->canUpdateUser->passes($object); + + $query = $this->fetchesUser->execute(['id' => $request->route('id')]); + + $query = $this->updatesUser->execute($query, $object); + + return $this->resourceResponse(new UserResource($query)); + + + } catch (\Exception $exception){ + throw new ErrorException($exception->getMessage(), $exception->getCode()); + } + + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Accounts/DataTransferObjects/UserObject.php b/app/Classes/Modules/Accounts/DataTransferObjects/UserObject.php new file mode 100644 index 00000000..b3988d3a --- /dev/null +++ b/app/Classes/Modules/Accounts/DataTransferObjects/UserObject.php @@ -0,0 +1,30 @@ +name = $name; + } + + /** + * @return string + */ + public function getName(): string + { + return $this->name; + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Accounts/Services/UpdatesUser.php b/app/Classes/Modules/Accounts/Services/UpdatesUser.php new file mode 100644 index 00000000..ef2e8d1a --- /dev/null +++ b/app/Classes/Modules/Accounts/Services/UpdatesUser.php @@ -0,0 +1,24 @@ +name = $object->getName(); + return $this->handler($model); + + } +} \ No newline at end of file diff --git a/app/Classes/Modules/Accounts/Standards/Rules/CanUpdateUser.php b/app/Classes/Modules/Accounts/Standards/Rules/CanUpdateUser.php new file mode 100644 index 00000000..a523ac12 --- /dev/null +++ b/app/Classes/Modules/Accounts/Standards/Rules/CanUpdateUser.php @@ -0,0 +1,57 @@ +userUpdateValidation = $userUpdateValidation; + } + + + /** + * @return bool + */ + protected function authorized(): bool + { + // TODO Set Authorization rules + return true; + + } + + /** + * @param UserObject $object + * @return bool + * @throws \App\Classes\Exceptions\RequestValidationException + */ + protected function validators($object): bool + { + return $this->userUpdateValidation->validate($object); + + } + + + /** + * @param AddressObject $object + * @return bool + */ + protected function criteria($object): bool + { + return true; + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Accounts/Standards/Validators/UserUpdateValidation.php b/app/Classes/Modules/Accounts/Standards/Validators/UserUpdateValidation.php new file mode 100644 index 00000000..9b2f8177 --- /dev/null +++ b/app/Classes/Modules/Accounts/Standards/Validators/UserUpdateValidation.php @@ -0,0 +1,40 @@ + $object->getName(), + ]; + } + + /** + * @return array + */ + protected function rules(): array + { + return [ + 'name' => 'required', + ]; + } + + /** + * @return array + */ + protected function messages(): array + { + return []; + } +} \ No newline at end of file diff --git a/app/Classes/Modules/Documents/Standards/Rules/CanListDocuments.php b/app/Classes/Modules/Documents/Standards/Rules/CanListDocuments.php index d94068b7..f5145df6 100644 --- a/app/Classes/Modules/Documents/Standards/Rules/CanListDocuments.php +++ b/app/Classes/Modules/Documents/Standards/Rules/CanListDocuments.php @@ -12,11 +12,13 @@ class CanListDocuments extends AbstractRule */ protected function authorized(): bool { - // TODO Set Authorization rules + /* + Disabled temporarily, will check back later if (!\Auth::user()->can('view document')) { return false; } + */ return true; diff --git a/app/Classes/Notifications/ResetPasswordEmail.php b/app/Classes/Notifications/ResetPasswordEmail.php index f7a84ab8..d2228e50 100644 --- a/app/Classes/Notifications/ResetPasswordEmail.php +++ b/app/Classes/Notifications/ResetPasswordEmail.php @@ -31,7 +31,7 @@ class ResetPasswordEmail extends AbstractEmail { return (new MailMessage) ->subject('Reset Password') - ->view('emails.account.reset_password', ['user' => $this->user, 'attempt' => $this->attempt]); + ->view('emails.accounts.reset_password', ['user' => $this->user, 'attempt' => $this->attempt]); } diff --git a/app/Http/Controllers/Accounts/GeneratePasswordResetController.php b/app/Http/Controllers/Accounts/GeneratePasswordResetController.php new file mode 100644 index 00000000..b7e305c7 --- /dev/null +++ b/app/Http/Controllers/Accounts/GeneratePasswordResetController.php @@ -0,0 +1,20 @@ +execute($request); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Accounts/ResetPasswordController.php b/app/Http/Controllers/Accounts/ResetPasswordController.php new file mode 100644 index 00000000..ab20502f --- /dev/null +++ b/app/Http/Controllers/Accounts/ResetPasswordController.php @@ -0,0 +1,20 @@ +execute($request); + } +} \ No newline at end of file diff --git a/database/seeds/AdminUserPermissionsTableSeeder.php b/database/seeds/AdminUserPermissionsTableSeeder.php index 0ab43f98..132184d7 100644 --- a/database/seeds/AdminUserPermissionsTableSeeder.php +++ b/database/seeds/AdminUserPermissionsTableSeeder.php @@ -3,7 +3,7 @@ use Illuminate\Database\Seeder; use Spatie\Permission\Models\Role; use Spatie\Permission\Models\Permission; - +use App\Classes\ValueObjects\Constants as Constants; use App\Models\User; class AdminUserPermissionsTableSeeder extends Seeder @@ -19,77 +19,121 @@ class AdminUserPermissionsTableSeeder extends Seeder app()['cache']->forget('spatie.permission.cache'); // admin permissions - Permission::create(['name' => 'view document', 'guard_name' => 'web']); - Permission::create(['name' => 'add document', 'guard_name' => 'web']); - Permission::create(['name' => 'edit document', 'guard_name' => 'web']); - Permission::create(['name' => 'delete document', 'guard_name' => 'web']); + $permissions = [ + ['name' => 'view document', 'guard_name' => 'web'], + ['name' => 'add document', 'guard_name' => 'web'], + ['name' => 'edit document', 'guard_name' => 'web'], + ['name' => 'delete document', 'guard_name' => 'web'], - Permission::create(['name' => 'view standard_segment', 'guard_name' => 'web']); - Permission::create(['name' => 'add standard_segment', 'guard_name' => 'web']); - Permission::create(['name' => 'edit standard_segment', 'guard_name' => 'web']); - Permission::create(['name' => 'delete standard_segment', 'guard_name' => 'web']); + ['name' => 'view standard_segment', 'guard_name' => 'web'], + ['name' => 'add standard_segment', 'guard_name' => 'web'], + ['name' => 'edit standard_segment', 'guard_name' => 'web'], + ['name' => 'delete standard_segment', 'guard_name' => 'web'], - Permission::create(['name' => 'view standard_segment_constant', 'guard_name' => 'web']); - Permission::create(['name' => 'add standard_segment_constant', 'guard_name' => 'web']); - Permission::create(['name' => 'edit standard_segment_constant', 'guard_name' => 'web']); - Permission::create(['name' => 'delete standard_segment_constant', 'guard_name' => 'web']); + ['name' => 'view standard_segment_constant', 'guard_name' => 'web'], + ['name' => 'add standard_segment_constant', 'guard_name' => 'web'], + ['name' => 'edit standard_segment_constant', 'guard_name' => 'web'], + ['name' => 'delete standard_segment_constant', 'guard_name' => 'web'], - Permission::create(['name' => 'view segment', 'guard_name' => 'web']); - Permission::create(['name' => 'add segment', 'guard_name' => 'web']); - Permission::create(['name' => 'edit segment', 'guard_name' => 'web']); - Permission::create(['name' => 'delete segment', 'guard_name' => 'web']); + ['name' => 'view segment', 'guard_name' => 'web'], + ['name' => 'add segment', 'guard_name' => 'web'], + ['name' => 'edit segment', 'guard_name' => 'web'], + ['name' => 'delete segment', 'guard_name' => 'web'], - Permission::create(['name' => 'view segment_constant', 'guard_name' => 'web']); - Permission::create(['name' => 'add segment_constant', 'guard_name' => 'web']); - Permission::create(['name' => 'edit segment_constant', 'guard_name' => 'web']); - Permission::create(['name' => 'delete segment_constant', 'guard_name' => 'web']); + ['name' => 'view segment_constant', 'guard_name' => 'web'], + ['name' => 'add segment_constant', 'guard_name' => 'web'], + ['name' => 'edit segment_constant', 'guard_name' => 'web'], + ['name' => 'delete segment_constant', 'guard_name' => 'web'], - Permission::create(['name' => 'view company_bank', 'guard_name' => 'web']); - Permission::create(['name' => 'add company_bank', 'guard_name' => 'web']); - Permission::create(['name' => 'edit company_bank', 'guard_name' => 'web']); - Permission::create(['name' => 'delete company_bank', 'guard_name' => 'web']); + ['name' => 'view company_bank', 'guard_name' => 'web'], + ['name' => 'add company_bank', 'guard_name' => 'web'], + ['name' => 'edit company_bank', 'guard_name' => 'web'], + ['name' => 'delete company_bank', 'guard_name' => 'web'], - Permission::create(['name' => 'view currency', 'guard_name' => 'web']); - Permission::create(['name' => 'add currency', 'guard_name' => 'web']); - Permission::create(['name' => 'edit currency', 'guard_name' => 'web']); - Permission::create(['name' => 'delete currency', 'guard_name' => 'web']); + ['name' => 'view currency', 'guard_name' => 'web'], + ['name' => 'add currency', 'guard_name' => 'web'], + ['name' => 'edit currency', 'guard_name' => 'web'], + ['name' => 'delete currency', 'guard_name' => 'web'], - Permission::create(['name' => 'view currency_rate', 'guard_name' => 'web']); - Permission::create(['name' => 'add currency_rate', 'guard_name' => 'web']); - Permission::create(['name' => 'edit currency_rate', 'guard_name' => 'web']); - Permission::create(['name' => 'delete currency_rate', 'guard_name' => 'web']); + ['name' => 'view currency_rate', 'guard_name' => 'web'], + ['name' => 'add currency_rate', 'guard_name' => 'web'], + ['name' => 'edit currency_rate', 'guard_name' => 'web'], + ['name' => 'delete currency_rate', 'guard_name' => 'web'], - Permission::create(['name' => 'view booking', 'guard_name' => 'web']); - Permission::create(['name' => 'add booking', 'guard_name' => 'web']); - Permission::create(['name' => 'edit booking', 'guard_name' => 'web']); - Permission::create(['name' => 'delete booking', 'guard_name' => 'web']); + ['name' => 'view booking', 'guard_name' => 'web'], + ['name' => 'add booking', 'guard_name' => 'web'], + ['name' => 'edit booking', 'guard_name' => 'web'], + ['name' => 'delete booking', 'guard_name' => 'web'] + ]; + + foreach ($permissions as $permission){ + Permission::updateOrCreate($permission,$permission); + } /////////////////////////////////////////////////////////////////////// - $shadow_admin_role = Role::create([ - 'name' => 'Shadow Admin', - 'guard_name' => 'web', - 'type' => 1, - ]); + $shadow_admin_role = Role::updateOrCreate( + ['name' => 'Shadow Admin'], + [ + 'name' => 'Shadow Admin', + 'guard_name' => 'web', + 'type' => 1, + ] + ); $shadow_admin_role->givePermissionTo(Permission::all()); - $admin = User::find(1); - $admin->assignRole($shadow_admin_role); + //Assign permission by user role/type not id + //$admin = User::find(1); + //$admin->assignRole($shadow_admin_role); + $shadow_admins = User::query()->whereIn('type',[Constants\RoleTypes::SHADOW_ADMIN])->get(); + foreach ($shadow_admins as $shadow_admin) { + $shadow_admin->assignRole($shadow_admin_role); + } /////////////////////////////////////////////////////////////////////// - $ultimate_admin_role = Role::create([ - 'name' => 'Ultimate Admin', - 'guard_name' => 'web', - 'type' => 1, - ]); + $ultimate_admin_role = Role::updateOrCreate( + ['name' => 'Ultimate Admin'], + [ + 'name' => 'Ultimate Admin', + 'guard_name' => 'web', + 'type' => 1, + ] + ); $ultimate_admin_role->givePermissionTo(Permission::all()); - $admin = User::find(2); - $admin->assignRole($ultimate_admin_role); + $super_admins = User::query()->whereIn('type',[Constants\RoleTypes::SUPER_ADMIN])->get(); + foreach ($super_admins as $super_admin) { + $super_admin->assignRole($ultimate_admin_role); + } + /* Disable normal admin role for now, will comeback later to this + $admin_role = Role::updateOrCreate( + ['name' => 'Admin'], + [ + 'name' => 'Admin', + 'guard_name' => 'web', + 'type' => 1, + ] + ); + + //Normal admin limited permissions + $admin_permissions = [ + $permissions[0]['name'], + $permissions[1]['name'], + $permissions[2]['name'], + $permissions[3]['name'], + ]; + + $admin_role->givePermissionTo(Permission::query()->whereIn('name',$admin_permissions)->get()); + + $admins = User::query()->whereIn('type',[Constants\RoleTypes::ADMIN])->get(); + foreach ($admins as $admin) { + $admin->assignRole($admin_role); + } + */ /////////////////////////////////////////////////////////////////////// } } diff --git a/resources/assets/vue/components/accounts/forms/ForgetPasswordFormComponent.vue b/resources/assets/vue/components/accounts/forms/ForgetPasswordFormComponent.vue index 6fa4ea8b..ddf52cde 100644 --- a/resources/assets/vue/components/accounts/forms/ForgetPasswordFormComponent.vue +++ b/resources/assets/vue/components/accounts/forms/ForgetPasswordFormComponent.vue @@ -6,27 +6,41 @@ {{error}} -
-
+
+
-
- - - - - + + +
+ +
+
+
+
+
+
+ +
+
+
+
+
+
+ Your password has been changed successfully +
-
-
-
Back to login
+ +
+
+
Request Reset Link
-
-
Request Reset Link
+
+
Back to login
@@ -59,7 +73,8 @@ methods:{ successHandler(){ this.$store.dispatch('toggleSection', {name: 'forgetPasswordSuccess', status: true}); - this.$store.dispatch('passwordResetEmail', {email: this.parameters.email}) + this.$store.dispatch('passwordResetEmail', {email: this.parameters.email}); + this.resetForm(); }, errorHandler(error){ this.error = error.message; diff --git a/resources/assets/vue/components/accounts/forms/LoginFormComponent.vue b/resources/assets/vue/components/accounts/forms/LoginFormComponent.vue index 454038a7..2e174168 100644 --- a/resources/assets/vue/components/accounts/forms/LoginFormComponent.vue +++ b/resources/assets/vue/components/accounts/forms/LoginFormComponent.vue @@ -18,7 +18,7 @@
-

Forgot password?

+

Forgot password?

Sign In
diff --git a/resources/assets/vue/components/accounts/forms/ResetPasswordFormComponent.vue b/resources/assets/vue/components/accounts/forms/ResetPasswordFormComponent.vue new file mode 100644 index 00000000..33947d06 --- /dev/null +++ b/resources/assets/vue/components/accounts/forms/ResetPasswordFormComponent.vue @@ -0,0 +1,93 @@ + + \ No newline at end of file diff --git a/resources/assets/vue/components/banks/forms/BankAccountFormComponent.vue b/resources/assets/vue/components/banks/forms/BankAccountFormComponent.vue index 30bf75c4..66624778 100644 --- a/resources/assets/vue/components/banks/forms/BankAccountFormComponent.vue +++ b/resources/assets/vue/components/banks/forms/BankAccountFormComponent.vue @@ -51,7 +51,7 @@
- +
diff --git a/resources/assets/vue/components/bookings/elements/PaymentVerificationComponent.vue b/resources/assets/vue/components/bookings/elements/PaymentVerificationComponent.vue index d8aaa0d1..19b6961b 100644 --- a/resources/assets/vue/components/bookings/elements/PaymentVerificationComponent.vue +++ b/resources/assets/vue/components/bookings/elements/PaymentVerificationComponent.vue @@ -63,7 +63,7 @@ {{item.original_currency.short_code}} {{(Math.round((item.original_amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
-
+
@@ -132,6 +132,9 @@ import componentHandler from '../../../general/mixins/componentHandler'; import staticFormHandler from '../../../general/mixins/staticFormHandler' export default { + props: { + no_action: Boolean + }, methods: { approvePayment(status){ this.isLoading = true; diff --git a/resources/assets/vue/components/bookings/sections/SupplierPendingOrdersSectionComponent.vue b/resources/assets/vue/components/bookings/sections/SupplierPendingOrdersSectionComponent.vue index f08e0e4c..c3bdc966 100644 --- a/resources/assets/vue/components/bookings/sections/SupplierPendingOrdersSectionComponent.vue +++ b/resources/assets/vue/components/bookings/sections/SupplierPendingOrdersSectionComponent.vue @@ -11,7 +11,7 @@
-
+
{{selectedSupplier.name}}
diff --git a/resources/assets/vue/components/companies/elements/CompanyListComponent.vue b/resources/assets/vue/components/companies/elements/CompanyListComponent.vue index e3da2853..9fe3c96a 100644 --- a/resources/assets/vue/components/companies/elements/CompanyListComponent.vue +++ b/resources/assets/vue/components/companies/elements/CompanyListComponent.vue @@ -1,13 +1,14 @@