From e916ae6e34739c06ef3ee7835ace727ccdfd09d3 Mon Sep 17 00:00:00 2001 From: Hana Zaraa Date: Mon, 24 Jul 2023 16:03:26 +0100 Subject: [PATCH] validate password in step1 installer --- bbbeasy-backend/app/src/Actions/Core/Install.php | 3 --- bbbeasy-backend/app/src/Models/Preset.php | 3 +-- bbbeasy-backend/app/src/Models/PresetSetting.php | 5 ++--- bbbeasy-frontend/src/components/Install.tsx | 14 ++++++++++++-- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/bbbeasy-backend/app/src/Actions/Core/Install.php b/bbbeasy-backend/app/src/Actions/Core/Install.php index 121ab7c4..7a2d0222 100644 --- a/bbbeasy-backend/app/src/Actions/Core/Install.php +++ b/bbbeasy-backend/app/src/Actions/Core/Install.php @@ -54,9 +54,6 @@ public function execute($f3, $params): void $setting = new Setting(); $dataChecker = new DataChecker(); - $dataChecker->verify($form['username'], Validator::length(4)->setName('username')); - $dataChecker->verify($form['email'], Validator::email()->setName('email')); - $dataChecker->verify($form['password'], Validator::length(8)->setName('password')); $dataChecker = $setting->checkSettingsData($dataChecker, $form); $dataChecker->verify($form['presetsConfig'], Validator::notEmpty()->setName('presetsConfig')); diff --git a/bbbeasy-backend/app/src/Models/Preset.php b/bbbeasy-backend/app/src/Models/Preset.php index cea32173..c4ccbb4a 100644 --- a/bbbeasy-backend/app/src/Models/Preset.php +++ b/bbbeasy-backend/app/src/Models/Preset.php @@ -217,8 +217,7 @@ public function getPresetSettings(): array $presetSett = new PresetSetting(); foreach ($attributes as $attribute) { - - $presetSettings = $presetSett->getByNameAndGroup($attribute,$categoryName); + $presetSettings = $presetSett->getByNameAndGroup($attribute, $categoryName); if (!$presetSettings->dry() && $presetSettings->enabled) { if (!$settings[$categoryName]) { diff --git a/bbbeasy-backend/app/src/Models/PresetSetting.php b/bbbeasy-backend/app/src/Models/PresetSetting.php index dafc2188..0ffa9dcd 100644 --- a/bbbeasy-backend/app/src/Models/PresetSetting.php +++ b/bbbeasy-backend/app/src/Models/PresetSetting.php @@ -126,14 +126,13 @@ public function getByName(string $name): self return $this; } - public function getByNameAndGroup(string $name,string $group): self + public function getByNameAndGroup(string $name, string $group): self { - $this->load(['name = ? and group = ? ', $name,$group]); + $this->load(['name = ? and group = ? ', $name, $group]); return $this; } - public function savePresetSettings(array $presets): bool|string { foreach ($presets as $preset) { diff --git a/bbbeasy-frontend/src/components/Install.tsx b/bbbeasy-frontend/src/components/Install.tsx index fd8b0d10..ebb29bf1 100644 --- a/bbbeasy-frontend/src/components/Install.tsx +++ b/bbbeasy-frontend/src/components/Install.tsx @@ -40,6 +40,7 @@ import { PresetType } from '../types/PresetType'; import axios from 'axios'; import { apiRoutes } from '../routing/backend-config'; +import usersService from 'services/users.service'; const { Step } = Steps; @@ -229,8 +230,17 @@ const Install = () => { const onFinish = () => { const stepsData: formType = stepForm.getFieldsValue(true); - - if (activeStep < steps.length - 1) { + if (activeStep == 0) { + setMessage(''); + usersService + .collect_users(stepsData) + .then(() => { + next(); + }) + .catch((error) => { + setMessage(error.response.data.message); + }); + } else if (activeStep < steps.length - 1) { next(); } else { //edit file