Repository navigation
Fix: Administrator utama bisa mengubah email hanya untuk akunnya sendiri - #1772
Merged
Merged
Conversation
Contributor
|
🔄 AI PR Review sedang antri di server...
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request: Fix: Administrator utama bisa mengubah email hanya untuk akunnya sendiri
Description
Sebelumnya field Email pada form edit pengguna (
resources/views/user/form.blade.php) selalureadonlyuntuk semua kondisi edit, sehingga administrator utama tidak bisa mengubah email akunnya sendiri. PR ini membuat field Email dapat diubah hanya ketika pengguna yang sedang login mengedit datanya sendiri, sedangkan saat mengedit pengguna lain field Email tetapreadonly.Changes made:
resources/views/user/form.blade.phpdiubah dariempty($user)menjadiempty($user) || auth()->id() == $user->id, sehingga email editable saat edit profil sendiritest_edit_form_email_is_readonly_when_editing_another_user— memastikan email tetapreadonlysaat super-admin mengedit user laintest_edit_form_email_is_editable_when_editing_own_profile— memastikan email tidakreadonlysaat user mengedit dirinya sendiri (test ini gagal sebelum perbaikan, lulus sesudahnya / TDD)pintpadatests/Feature/UserControllerTest.php: urutan import, hapus importHashyang tidak terpakai, dan penamaan methodtest_get_data_user_returns_json_response(snake_case)Reason for change:
readonlypada mode edit membuat administrator utama tidak dapat memperbarui email akunnya sendiri (issue Bug: Administrator utama tidak bisa edit email #1771)UserRequestmaupun alur update controllerImpact of change:
✅ Administrator utama: Dapat mengubah email akunnya sendiri melalui menu profil
✅ Keamanan: Saat mengedit user lain, field Email tetap terkunci (
readonly)✅ Regresi: Seluruh test CRUD pengguna tetap lulus (26 test)
Related Issue
Steps to Reproduce
Before fix (problem):
readonly, tidak bisa diubahAfter fix (solution):
readonlyTesting on related features:
Checklist
Technical Details
Technical Explanation
Perubahan kondisi pada bagian Email di
resources/views/user/form.blade.php:$userkosong): email tetap editable seperti sebelumnyaauth()->id() == $user->id): email editable (perbaikan bug)readonlyCatatan untuk reviewer: penguncian ini hanya berlaku di tampilan.
UserController::update()beserta rulesUserRequesttidak diubah, sehingga super-admin yang mengirim request manual untuk user lain masih dapat mengubah email (diperlukan keputusan terpisah bila ingin diperkuat di backend).Configuration changes
Tidak ada perubahan konfigurasi
Dependencies added
No new dependencies
Testing
Manual Testing
readonlyAutomated Testing
UserControllerTest::test_edit_form_email_is_readonly_when_editing_another_userUserControllerTest::test_edit_form_email_is_editable_when_editing_own_profilephp vendor/bin/pest tests/Feature/UserControllerTest.php tests/Feature/Settings/UserManagementCrudTest.php→ 26 passedScreenshots / Video
Before:
Field Email pada form edit selalu memiliki atribut
readonly(abu-abu, tidak bisa diketik).After:
Field Email dapat diketik saat mengedit akun sendiri; tetap
readonlysaat mengedit akun lain.Breaking Changes
None
Migration Guide
Not required
References
fix/izinkan_ubah_email→rilis-devAdditional notes: Perubahan tampilan saja (1 baris Blade) + 2 test baru. Bila issue ini juga menuntut pembatasan di backend, perlu diskusi terpisah karena ada test lama
test_update_updates_user_successfully_for_super_adminyang mengasumsikan super-admin dapat mengubah email user lain.