patch for user
This commit is contained in:
parent
f5662129b7
commit
a0cd66f5f2
@ -149,7 +149,7 @@ class UserController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Put(
|
||||
* @OA\Patch(
|
||||
* path="/api/users/{id}",
|
||||
* summary="Update an existing user (only admin)",
|
||||
* tags={"Users"},
|
||||
@ -209,14 +209,14 @@ class UserController extends Controller
|
||||
{
|
||||
$this->authorize('update', $user);
|
||||
$fields = $request->validate([
|
||||
'username' => ['required', 'max:100', Rule::unique('users')->ignore($user->id)],
|
||||
'email' => ['required', 'max:100', Rule::unique('users')->ignore($user->id)],
|
||||
'password' => 'required|min:6',
|
||||
'type' => 'required|in:admin,user,creator,banned',
|
||||
'email_verified_at' => 'nullable|date',
|
||||
'username' => ['sometimes', 'max:100', Rule::unique('users')->ignore($user->id)],
|
||||
'email' => ['sometimes', 'max:100', Rule::unique('users')->ignore($user->id)],
|
||||
'password' => 'sometimes|min:6',
|
||||
'type' => 'sometimes|in:admin,user,creator,banned',
|
||||
'email_verified_at' => 'sometimes|date',
|
||||
]);
|
||||
|
||||
if(!Hash::check($fields['password'], $user->password)) {
|
||||
if (isset($fields['password'])) {
|
||||
$fields['password'] = Hash::make($fields['password']);
|
||||
}
|
||||
$user->update($fields);
|
||||
|
||||
@ -2162,12 +2162,50 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"put": {
|
||||
"delete": {
|
||||
"tags": [
|
||||
"Users"
|
||||
],
|
||||
"summary": "Delete a user (only admin)",
|
||||
"operationId": "fa56cffde745d3f152f95cbacd936c0b",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"description": "User ID",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"example": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": "User deleted successfully (no content)"
|
||||
},
|
||||
"404": {
|
||||
"description": "User not found"
|
||||
},
|
||||
"403": {
|
||||
"description": "Forbidden — only admins can delete users"
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthenticated"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"bearerAuth": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"patch": {
|
||||
"tags": [
|
||||
"Users"
|
||||
],
|
||||
"summary": "Update an existing user (only admin)",
|
||||
"operationId": "b9091397c8b25f12c6adb74be6ce3a5a",
|
||||
"operationId": "872a537e8eb13c26c5542c7d73269a80",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
@ -2275,44 +2313,6 @@
|
||||
"bearerAuth": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"delete": {
|
||||
"tags": [
|
||||
"Users"
|
||||
],
|
||||
"summary": "Delete a user (only admin)",
|
||||
"operationId": "fa56cffde745d3f152f95cbacd936c0b",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"description": "User ID",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"example": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": "User deleted successfully (no content)"
|
||||
},
|
||||
"404": {
|
||||
"description": "User not found"
|
||||
},
|
||||
"403": {
|
||||
"description": "Forbidden — only admins can delete users"
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthenticated"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"bearerAuth": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/user-tests/me": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user