-
-
Notifications
You must be signed in to change notification settings - Fork 233
Add api endpoint for updating username #1826
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
Changes from all commits
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,38 @@ | ||
| <?php | ||
|
|
||
| namespace App\Http\Requests\Api\Client\Account; | ||
|
|
||
| use App\Exceptions\Http\Base\InvalidPasswordProvidedException; | ||
| use App\Http\Requests\Api\Client\ClientApiRequest; | ||
| use App\Models\User; | ||
| use Illuminate\Container\Container; | ||
| use Illuminate\Contracts\Hashing\Hasher; | ||
|
|
||
| class UpdateUsernameRequest extends ClientApiRequest | ||
| { | ||
| /** | ||
| * @throws InvalidPasswordProvidedException | ||
| */ | ||
| public function authorize(): bool | ||
| { | ||
| if (!parent::authorize()) { | ||
| return false; | ||
| } | ||
|
|
||
| $hasher = Container::getInstance()->make(Hasher::class); | ||
|
|
||
| // Verify password matches when changing password or email. | ||
notAreYouScared marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (!$hasher->check($this->input('password'), $this->user()->password)) { | ||
| throw new InvalidPasswordProvidedException(trans('validation.internal.invalid_password')); | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| public function rules(): array | ||
| { | ||
| $rules = User::getRulesForUpdate($this->user()); | ||
|
|
||
| return ['username' => $rules['username']]; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ | |
| Route::prefix('/account')->middleware(AccountSubject::class)->group(function () { | ||
| Route::get('/', [Client\AccountController::class, 'index'])->name('api:client.account'); | ||
|
|
||
| Route::put('/username', [Client\AccountController::class, 'updateUsername'])->name('api:client.account.update-username'); | ||
|
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. 🧩 Analysis chainLGTM — route mirrors existing email/password endpoints. Add/verify API docs and tests cover this new route and name. 🏁 Script executed: #!/bin/bash
# Find route, method, and tests/usages.
rg -nC2 $'/account/username|updateUsername|api:client.account.update-username'Length of output: 1067 I can see the route, controller method, and parallel endpoints exist. Now I need to verify if API documentation and tests cover this route.<!-- [scratchpad_update] [actions]
🏁 Script executed: #!/bin/bash
# Search for test files related to AccountController or updateUsername
find tests -type f -name "*.php" 2>/dev/null | xargs grep -l "updateUsername\|AccountController\|account.*update\|api:client.account" 2>/dev/null | head -20Length of output: 120 🏁 Script executed: #!/bin/bash
# Search for API documentation files
find . -type f \( -name "*api*doc*" -o -name "*.md" -o -name "openapi*" -o -name "swagger*" \) 2>/dev/null | grep -v node_modules | head -20Length of output: 92 🏁 Script executed: #!/bin/bash
# Look for test directories and their structure
find tests -type d | head -30Length of output: 927 🏁 Script executed: #!/bin/bash
# Check for any test files in tests directory
ls -la tests/ 2>/dev/null || echo "tests directory not found or empty"Length of output: 587 🏁 Script executed: #!/bin/bash
# Check AccountControllerTest.php for updateUsername test coverage
cat tests/Integration/Api/Client/AccountControllerTest.phpLength of output: 7059 🏁 Script executed: #!/bin/bash
# Search markdown files for API documentation about this endpoint
grep -r "username\|account.*update\|/account/" readme.md contributing.md 2>/dev/null || echo "No matches in main docs"Length of output: 23 Tests are missing for the new The route is well-formed and mirrors the email/password endpoints, but 🤖 Prompt for AI Agents |
||
| Route::put('/email', [Client\AccountController::class, 'updateEmail'])->name('api:client.account.update-email'); | ||
| Route::put('/password', [Client\AccountController::class, 'updatePassword'])->name('api:client.account.update-password'); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.