Skip to content

Commit 37e4f88

Browse files
committed
Fix: Prevent unauthorized role assignment in registration
- Removed client-side 'role_id' input to prevent unauthorized role manipulation. - Set default 'role_id' to 2 (customer) directly in `AuthController`, ensuring only authorized roles are assigned server-side.
1 parent 2d53ba7 commit 37e4f88

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

app/Http/Controllers/AuthController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ public function registrationPost(Request $request)
5454
'phone' => 'required|numeric',
5555
'gender' => 'required',
5656
'address' => 'required',
57-
'role_id' => 'required|numeric',
5857
]);
5958

6059
$validatedData['password'] = Hash::make($validatedData['password']);
@@ -63,6 +62,7 @@ public function registrationPost(Request $request)
6362
"coupon" => 0,
6463
"point" => 0,
6564
'remember_token' => Str::random(30),
65+
'role_id' => 2 // value 2 for customer role
6666
]);
6767

6868
try {

resources/views/auth/register.blade.php

-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ class="form-control @error('password_confirmation') is-invalid @enderror"
9393
<div class="text-danger">{{ $message }}</div>
9494
@enderror
9595
</div>
96-
<input type="hidden" name="role_id" value="2" /> {{-- role 2 for customer --}}
9796
<button type="submit" class="btn btn-info btn-block">
9897
Submit
9998
</button>

0 commit comments

Comments
 (0)