-
Notifications
You must be signed in to change notification settings - Fork 1
fix: сделать пароль необязательным при обновлении пользователя #21
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
Conversation
Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: undefined
Исправлена проблема валидации при обновлении пользователя через PUT /api/v1/users/{id}:
- Изменена валидация пароля с 'required' на 'nullable' для корректной работы с пустыми строками
- Пароль теперь обновляется только если он предоставлен и не пустой
- Добавлена поддержка поля 'phone' в дополнение к 'phone_number' для обратной совместимости
- Удалено сообщение об ошибке 'password.required' из валидации
Теперь при отправке пустого пароля ("") пароль не изменяется и не выскакивает ошибка валидации.
При вводе нового пароля он корректно обновляется.
Fixes xierongchuan#20
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This reverts commit 419c064.
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 📎 Log file uploaded as GitHub Gist (203KB) Now working session is ended, feel free to review and add any feedback on the solution draft. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 issues found across 2 files
Prompt for AI agents (all 2 issues)
Understand the root cause of the following 2 issues and fix them.
<file name="app/Http/Controllers/Api/V1/UserApiController.php">
<violation number="1" location="app/Http/Controllers/Api/V1/UserApiController.php:135">
Switching the password rule to nullable doesn’t let an empty string through—`min:8` and the regex still run on "", so the update request with `"password": ""` will keep failing validation. Please also skip the other rules when the value is empty (e.g. convert the empty string to null or add an `exclude_if` rule) so the intended case succeeds.</violation>
</file>
<file name="CLAUDE.md">
<violation number="1" location="CLAUDE.md:332">
Please remove this automation metadata block; it marks the issue as "undefined" and includes environment-specific paths/branch references that don’t apply to contributors, leaving misleading documentation in the repo.</violation>
</file>
React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.
| 'password' => [ | ||
| 'sometimes', | ||
| 'required', | ||
| 'nullable', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switching the password rule to nullable doesn’t let an empty string through—min:8 and the regex still run on "", so the update request with "password": "" will keep failing validation. Please also skip the other rules when the value is empty (e.g. convert the empty string to null or add an exclude_if rule) so the intended case succeeds.
Prompt for AI agents
Address the following comment on app/Http/Controllers/Api/V1/UserApiController.php at line 135:
<comment>Switching the password rule to nullable doesn’t let an empty string through—`min:8` and the regex still run on "", so the update request with `"password": ""` will keep failing validation. Please also skip the other rules when the value is empty (e.g. convert the empty string to null or add an `exclude_if` rule) so the intended case succeeds.</comment>
<file context>
@@ -132,7 +132,7 @@ public function update(Request $request, $id): JsonResponse
'password' => [
'sometimes',
- 'required',
+ 'nullable',
'string',
'min:8',
</file context>
CLAUDE.md
Outdated
| --- | ||
|
|
||
| Issue to solve: undefined | ||
| Your prepared branch: issue-20-33c45069 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this automation metadata block; it marks the issue as "undefined" and includes environment-specific paths/branch references that don’t apply to contributors, leaving misleading documentation in the repo.
Prompt for AI agents
Address the following comment on CLAUDE.md at line 332:
<comment>Please remove this automation metadata block; it marks the issue as "undefined" and includes environment-specific paths/branch references that don’t apply to contributors, leaving misleading documentation in the repo.</comment>
<file context>
@@ -324,4 +324,14 @@ Copyright: © 2023-2025 谢榕川 All rights reserved
+---
+
+Issue to solve: undefined
+Your prepared branch: issue-20-33c45069
+Your prepared working directory: /tmp/gh-issue-solver-1761684565756
+Your forked repository: konard/TaskMateTelegramBot
</file context>
📋 Описание проблемы
Fixes #20
При обновлении пользователя через эндпоинт
PUT /api/v1/users/{id}с пустым паролем возникала ошибка валидации:Запрос:
{ "login": "admin", "full_name": "Supreme Admin", "phone": "+998934958514", "role": "owner", "password": "" }Ответ (ошибка):
{ "success": false, "message": "Ошибка валидации", "errors": { "password": [ "Пароль обязателен" ] } }🔧 Реализованное решение
Изменения в
UserApiController.phpИсправлена валидация пароля:
'required'на'nullable''password.required'Условное обновление пароля:
$validated['password'] !== '' && $validated['password'] !== null$updateDataПоддержка обоих форматов поля телефона:
'phone'(кроме существующего'phone_number')'phone'✅ Результат
Теперь эндпоинт работает корректно:
"") - пароль не меняется, ошибки нетphoneиphone_number📝 Измененные файлы
app/Http/Controllers/Api/V1/UserApiController.php- методupdate()🧪 Тестирование
Рекомендуется протестировать следующие сценарии:
password- должно работатьpassword: ""- должно работать без ошибкиphoneвместоphone_number- должно работать🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com