-
-
Notifications
You must be signed in to change notification settings - Fork 112
fix(user, composer): removing martial status, dependencies (fixes #1587) #1590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 5 commits
17905c0
6c38315
63dd14d
8d9ca1f
f202690
950bd92
02681fb
cdc741f
bb53df7
9377e72
b21d088
c14ef60
17f3ecb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace openvk\CLI; | ||
|
|
||
| use Chandler\Security\User as ChandlerUser; | ||
| use openvk\Web\Models\Entities\User; | ||
| use openvk\Web\Models\Exceptions\InvalidUserNameException; | ||
| use openvk\Web\Util\Validator; | ||
| use Random\RandomException; | ||
| use Symfony\Component\Console\Command\Command; | ||
| use Symfony\Component\Console\Input\InputInterface; | ||
| use Symfony\Component\Console\Input\InputOption; | ||
| use Symfony\Component\Console\Output\OutputInterface; | ||
| use Symfony\Component\Console\Style\SymfonyStyle; | ||
|
|
||
|
|
||
| class GenerateUsersCommand extends Command | ||
| { | ||
| protected static $defaultName = "generate-users"; | ||
| protected function configure(): void | ||
| { | ||
| $this->setDescription("Generate test user accounts for development") | ||
| ->addOption( | ||
| "count", | ||
| "c", | ||
| InputOption::VALUE_REQUIRED, | ||
| "Number of users to create", | ||
| 1 | ||
| ); | ||
| } | ||
|
|
||
| //Duplicate the logic from the Web/Presenters/AuthPresenter.php class | ||
| /** | ||
| * @throws RandomException | ||
| */ | ||
| protected function execute(InputInterface $input, OutputInterface $output): int | ||
| { | ||
| $io = new SymfonyStyle($input, $output); | ||
| $count = (int) $input->getOption("count"); | ||
|
|
||
| if ($count < 1) { | ||
| $io->error("Count must be at least 1."); | ||
|
|
||
| return Command::FAILURE; | ||
| } | ||
|
|
||
| $created = []; | ||
| $prefixTimeForEmail = dechex(time()); | ||
|
|
||
| for ($i = 1; $i <= $count; $i++) { | ||
| $email = "generated.{$prefixTimeForEmail}.{$i}@localhost.localdomain"; | ||
| $password = $this->generatePassword(); | ||
|
|
||
| try { | ||
| $user = new User(); | ||
| $user->setFirst_Name("Test"); | ||
| $user->setLast_Name('TEST LAST NAME'); | ||
| $user->setSex(0); | ||
| $user->setEmail($email); | ||
| $user->setSince(date("Y-m-d H:i:s")); | ||
| $user->setRegistering_Ip("127.0.0.1"); | ||
| $user->setBirthday(strtotime("1999-01-01")); | ||
| $user->setActivated(1); | ||
| } catch (InvalidUserNameException $ex) { | ||
| $io->error("Failed to set name for user #{$i}: " . $ex->getMessage()); | ||
|
|
||
| return Command::FAILURE; | ||
| } | ||
|
|
||
| $chUser = ChandlerUser::create($email, $password); | ||
| if (!$chUser) { | ||
| $io->error("Failed to create Chandler user for {$email}"); | ||
|
|
||
| return Command::FAILURE; | ||
| } | ||
|
|
||
| $user->setUser($chUser->getId()); | ||
| $user->save(false); | ||
|
|
||
| $created[] = [ | ||
| "id" => $user->getId(), | ||
| "email" => $email, | ||
| "password" => $password, | ||
| "url" => "/id" . $user->getId(), | ||
| ]; | ||
| } | ||
|
|
||
| $io->success("Created " . count($created) . " user(s)."); | ||
|
|
||
| $rows = array_map(static fn(array $u): array => [ | ||
| $u["id"], | ||
| $u["email"], | ||
| $u["password"], | ||
| $u["url"], | ||
| ], $created); | ||
|
|
||
| $io->table(["ID", "Email", "Password", "Profile URL"], $rows); | ||
|
|
||
| return Command::SUCCESS; | ||
| } | ||
|
|
||
| /** | ||
| * @throws RandomException | ||
| */ | ||
| private function generatePassword(): string | ||
| { | ||
| do { | ||
| $password = "OvK" . bin2hex(random_bytes(4)) . "A1"; | ||
| } while (!Validator::i()->passwordStrong($password)); | ||
|
|
||
| return $password; | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -125,8 +125,8 @@ | |
| n:attr="style => $user->getMaritalStatusUser() || ($user->getMaritalStatus() && !in_array($user->getMaritalStatus(), [0, 1, 8])) ? '' : 'display: none;'"> | ||
| <td width="120" valign="top"></td> | ||
| <td> | ||
| <input type="text" placeholder="{_page_address}" name="maritalstatus-user" | ||
| n:attr="value => $user->getMaritalStatusUser() ? $user->getMaritalStatusUser()->getId() : ''" /> | ||
| <input type="text" placeholder="{_marital_status_user_id}" name="maritalstatus-user" | ||
| n:attr="value => $user->getMaritalStatusUser() ? ltrim($user->getMaritalStatusUser()->getURL(), '/') : ''" /> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. вместо того, чтобы городить костыли с ltrim, можно было создать в объекте User отдельную функцию для screenname
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. В корне не согласен. Для показа чего либо во вьюхе совсем не повод захломлять методами и без того большую модель. Модель в целом должна использоваться для возрата данных в данном случае а стилизация текста это задача самой вьюхи.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Исключением может быть yii2 😭
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Рефакторы только после тестов, пожалуйста
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Остаюсь на своём - это костыли. В API используется (увы) один уже такой связанный со screen_name (он просто повторяет функцию, без
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Это более рациональное решение, добавил b21d088 |
||
| </td> | ||
| </tr> | ||
| <tr> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ | |
| "analyse": "phpstan analyse --memory-limit 1G" | ||
| }, | ||
| "require": { | ||
| "php": "~7.3||~8.1", | ||
| "php": "~7.3||~8.2", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Не видел инстансов, где 7 пыха всё ещё используется, можно смело дропать, но это лучше оставить на другой ПР, ибо придётся тянуть изменения в доках
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. солидарен, лучше дропнуть отдельным PR. 7.3 и уж тем более 7.4 уже 4 года как EOL, дистры его не предоставляют в пакетах
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. вернул версию - revert(composer.json): revert php version
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Создал отдельный ПР - #1592 |
||
| "whichbrowser/parser": "dev-master", | ||
| "james-heinrich/getid3": "^1.9@dev", | ||
| "rybakit/msgpack": "dev-master", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -339,6 +339,7 @@ | |
| "your_email_address" = "Adras Vašaj elektronaj pošty"; | ||
| "your_page_address" = "Adras Vašaj staronki"; | ||
| "page_address" = "Adras staronki"; | ||
| "marital_status_user_id" = "ID karystálnika"; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. не трогайте плиз локали на языках которых вы не разговариваете. этим занимаются переводчики
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Мне писать все в латиницу или вообще не писать ключи на другие strings ?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Все языки фолбэчатся на русский или английский. Как следствие, русского и английского достаточно
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. исчерпывающий ответ @WerySkok
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| "current_email_address" = "Ciapierašni adras"; | ||
| "page_id" = "ID staronki"; | ||
| "you_can_also" = "Vy majecie racyju"; | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.