Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/API/V4/UsersController.php
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | public function destroy($id) | ||||
if (!$this->guard()->user()->canDelete($user)) { | if (!$this->guard()->user()->canDelete($user)) { | ||||
return $this->errorResponse(403); | return $this->errorResponse(403); | ||||
} | } | ||||
$user->delete(); | $user->delete(); | ||||
return response()->json([ | return response()->json([ | ||||
'status' => 'success', | 'status' => 'success', | ||||
'message' => __('app.user-delete-success'), | 'message' => \trans('app.user-delete-success'), | ||||
]); | ]); | ||||
} | } | ||||
/** | /** | ||||
* Listing of users. | * Listing of users. | ||||
* | * | ||||
* The user-entitlements billed to the current user wallet(s) | * The user-entitlements billed to the current user wallet(s) | ||||
* | * | ||||
Show All 34 Lines | public function setConfig($id) | ||||
$errors = $user->setConfig(request()->input()); | $errors = $user->setConfig(request()->input()); | ||||
if (!empty($errors)) { | if (!empty($errors)) { | ||||
return response()->json(['status' => 'error', 'errors' => $errors], 422); | return response()->json(['status' => 'error', 'errors' => $errors], 422); | ||||
} | } | ||||
return response()->json([ | return response()->json([ | ||||
'status' => 'success', | 'status' => 'success', | ||||
'message' => __('app.user-setconfig-success'), | 'message' => \trans('app.user-setconfig-success'), | ||||
]); | ]); | ||||
} | } | ||||
/** | /** | ||||
* Display information on the user account specified by $id. | * Display information on the user account specified by $id. | ||||
* | * | ||||
* @param int $id The account to show information for. | * @param int $id The account to show information for. | ||||
* | * | ||||
▲ Show 20 Lines • Show All 229 Lines • ▼ Show 20 Lines | public function store(Request $request) | ||||
if (!empty($request->aliases)) { | if (!empty($request->aliases)) { | ||||
$user->setAliases($request->aliases); | $user->setAliases($request->aliases); | ||||
} | } | ||||
DB::commit(); | DB::commit(); | ||||
return response()->json([ | return response()->json([ | ||||
'status' => 'success', | 'status' => 'success', | ||||
'message' => __('app.user-create-success'), | 'message' => \trans('app.user-create-success'), | ||||
]); | ]); | ||||
} | } | ||||
/** | /** | ||||
* Update user data. | * Update user data. | ||||
* | * | ||||
* @param \Illuminate\Http\Request $request The API request. | * @param \Illuminate\Http\Request $request The API request. | ||||
* @param string $id User identifier | * @param string $id User identifier | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | public function update(Request $request, $id) | ||||
// TODO: Make sure that UserUpdate job is created in case of entitlements update | // TODO: Make sure that UserUpdate job is created in case of entitlements update | ||||
// and no password change. So, for example quota change is applied to LDAP | // and no password change. So, for example quota change is applied to LDAP | ||||
// TODO: Review use of $user->save() in the above context | // TODO: Review use of $user->save() in the above context | ||||
DB::commit(); | DB::commit(); | ||||
$response = [ | $response = [ | ||||
'status' => 'success', | 'status' => 'success', | ||||
'message' => __('app.user-update-success'), | 'message' => \trans('app.user-update-success'), | ||||
]; | ]; | ||||
// For self-update refresh the statusInfo in the UI | // For self-update refresh the statusInfo in the UI | ||||
if ($user->id == $current_user->id) { | if ($user->id == $current_user->id) { | ||||
$response['statusInfo'] = self::statusInfo($user); | $response['statusInfo'] = self::statusInfo($user); | ||||
} | } | ||||
return response()->json($response); | return response()->json($response); | ||||
▲ Show 20 Lines • Show All 415 Lines • Show Last 20 Lines |