use OC\AppConfig;
use OC\AppFramework\Middleware\Security\Exceptions\NotAdminException;
use OCP\AppFramework\Http;
+use OCP\AppFramework\Http\Attribute\NoAdminRequired;
+use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
use OCP\IAppConfig;
}
/**
- * @PasswordConfirmationRequired
* @NoSubAdminRequired
- * @NoAdminRequired
*
* Update the config value of an app
*
* 200: Value updated successfully
* 403: App or key is not allowed
*/
+ #[PasswordConfirmationRequired]
+ #[NoAdminRequired]
public function setValue(string $app, string $key, string $value): DataResponse {
$user = $this->userSession->getUser();
if ($user === null) {
}
/**
- * @PasswordConfirmationRequired
- *
* Delete a config key of an app
*
* @param string $app ID of the app
* 200: Key deleted successfully
* 403: App or key is not allowed
*/
+ #[PasswordConfirmationRequired]
public function deleteKey(string $app, string $key): DataResponse {
try {
$this->verifyAppId($app);
use OCP\App\AppPathNotFoundException;
use OCP\App\IAppManager;
use OCP\AppFramework\Http;
+use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSException;
use OCP\AppFramework\OCSController;
}
/**
- * @PasswordConfirmationRequired
- *
* Enable an app
*
* @param string $app ID of the app
*
* 200: App enabled successfully
*/
+ #[PasswordConfirmationRequired]
public function enable(string $app): DataResponse {
try {
$this->appManager->enableApp($app);
}
/**
- * @PasswordConfirmationRequired
- *
* Disable an app
*
* @param string $app ID of the app
*
* 200: App disabled successfully
*/
+ #[PasswordConfirmationRequired]
public function disable(string $app): DataResponse {
$this->appManager->disableApp($app);
return new DataResponse();
namespace OCA\Provisioning_API\Controller;
use OCA\Provisioning_API\ResponseDefinitions;
+use OCA\Settings\Settings\Admin\Sharing;
use OCA\Settings\Settings\Admin\Users;
use OCP\Accounts\IAccountManager;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\AuthorizedAdminSetting;
+use OCP\AppFramework\Http\Attribute\NoAdminRequired;
+use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSException;
use OCP\AppFramework\OCS\OCSForbiddenException;
}
/**
- * @NoAdminRequired
- *
* Get a list of groups
*
* @param string $search Text to search for
*
* 200: Groups returned
*/
+ #[NoAdminRequired]
public function getGroups(string $search = '', ?int $limit = null, int $offset = 0): DataResponse {
$groups = $this->groupManager->search($search, $limit, $offset);
$groups = array_map(function ($group) {
}
/**
- * @NoAdminRequired
- * @AuthorizedAdminSetting(settings=OCA\Settings\Settings\Admin\Sharing)
- *
* Get a list of groups details
*
* @param string $search Text to search for
*
* 200: Groups details returned
*/
+ #[NoAdminRequired]
+ #[AuthorizedAdminSetting(settings: Sharing::class)]
public function getGroupsDetails(string $search = '', ?int $limit = null, int $offset = 0): DataResponse {
$groups = $this->groupManager->search($search, $limit, $offset);
$groups = array_map(function ($group) {
}
/**
- * @NoAdminRequired
- *
* Get a list of users in the specified group
*
* @param string $groupId ID of the group
*
* 200: Group users returned
*/
+ #[NoAdminRequired]
public function getGroup(string $groupId): DataResponse {
return $this->getGroupUsers($groupId);
}
/**
- * @NoAdminRequired
- *
* Get a list of users in the specified group
*
* @param string $groupId ID of the group
*
* 200: User IDs returned
*/
+ #[NoAdminRequired]
public function getGroupUsers(string $groupId): DataResponse {
$groupId = urldecode($groupId);
}
/**
- * @NoAdminRequired
- *
* Get a list of users details in the specified group
*
* @param string $groupId ID of the group
*
* 200: Group users details returned
*/
+ #[NoAdminRequired]
public function getGroupUsersDetails(string $groupId, string $search = '', ?int $limit = null, int $offset = 0): DataResponse {
$groupId = urldecode($groupId);
$currentUser = $this->userSession->getUser();
}
/**
- * @PasswordConfirmationRequired
- *
* Create a new group
*
* @param string $groupid ID of the group
* 200: Group created successfully
*/
#[AuthorizedAdminSetting(settings:Users::class)]
+ #[PasswordConfirmationRequired]
public function addGroup(string $groupid, string $displayname = ''): DataResponse {
// Validate name
if (empty($groupid)) {
}
/**
- * @PasswordConfirmationRequired
- *
* Update a group
*
* @param string $groupId ID of the group
* 200: Group updated successfully
*/
#[AuthorizedAdminSetting(settings:Users::class)]
+ #[PasswordConfirmationRequired]
public function updateGroup(string $groupId, string $key, string $value): DataResponse {
$groupId = urldecode($groupId);
}
/**
- * @PasswordConfirmationRequired
- *
* Delete a group
*
* @param string $groupId ID of the group
* 200: Group deleted successfully
*/
#[AuthorizedAdminSetting(settings:Users::class)]
+ #[PasswordConfirmationRequired]
public function deleteGroup(string $groupId): DataResponse {
$groupId = urldecode($groupId);
namespace OCA\Provisioning_API\Controller;
use OCP\AppFramework\Http;
+use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
use OCP\Config\BeforePreferenceDeletedEvent;
}
/**
- * @NoAdminRequired
* @NoSubAdminRequired
*
* Update multiple preference values of an app
* 200: Preferences updated successfully
* 400: Preference invalid
*/
+ #[NoAdminRequired]
public function setMultiplePreferences(string $appId, array $configs): DataResponse {
$userId = $this->userSession->getUser()->getUID();
}
/**
- * @NoAdminRequired
* @NoSubAdminRequired
*
* Update a preference value of an app
* 200: Preference updated successfully
* 400: Preference invalid
*/
+ #[NoAdminRequired]
public function setPreference(string $appId, string $configKey, string $configValue): DataResponse {
$userId = $this->userSession->getUser()->getUID();
}
/**
- * @NoAdminRequired
* @NoSubAdminRequired
*
* Delete multiple preferences for an app
* 200: Preferences deleted successfully
* 400: Preference invalid
*/
+ #[NoAdminRequired]
public function deleteMultiplePreference(string $appId, array $configKeys): DataResponse {
$userId = $this->userSession->getUser()->getUID();
}
/**
- * @NoAdminRequired
* @NoSubAdminRequired
*
* Delete a preference for an app
* 200: Preference deleted successfully
* 400: Preference invalid
*/
+ #[NoAdminRequired]
public function deletePreference(string $appId, string $configKey): DataResponse {
$userId = $this->userSession->getUser()->getUID();
use OCP\Accounts\PropertyDoesNotExistException;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\AuthorizedAdminSetting;
+use OCP\AppFramework\Http\Attribute\NoAdminRequired;
+use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired;
+use OCP\AppFramework\Http\Attribute\UserRateLimit;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSException;
use OCP\AppFramework\OCS\OCSForbiddenException;
}
/**
- * @NoAdminRequired
- *
* Get a list of users
*
* @param string $search Text to search for
*
* 200: Users returned
*/
+ #[NoAdminRequired]
public function getUsers(string $search = '', ?int $limit = null, int $offset = 0): DataResponse {
$user = $this->userSession->getUser();
$users = [];
}
/**
- * @NoAdminRequired
- *
* Get a list of users and their details
*
* @param string $search Text to search for
*
* 200: Users details returned
*/
+ #[NoAdminRequired]
public function getUsersDetails(string $search = '', ?int $limit = null, int $offset = 0): DataResponse {
$currentUser = $this->userSession->getUser();
$users = [];
}
/**
- * @NoAdminRequired
- *
* Get the list of disabled users and their details
*
* @param string $search Text to search for
*
* 200: Disabled users details returned
*/
+ #[NoAdminRequired]
public function getDisabledUsersDetails(string $search = '', ?int $limit = null, int $offset = 0): DataResponse {
$currentUser = $this->userSession->getUser();
if ($currentUser === null) {
/**
- * @NoAdminRequired
* @NoSubAdminRequired
*
* Search users by their phone numbers
* 200: Users returned
* 400: Invalid location
*/
+ #[NoAdminRequired]
public function searchByPhoneNumbers(string $location, array $search): DataResponse {
if ($this->phoneNumberUtil->getCountryCodeForRegion($location) === null) {
// Not a valid region code
}
/**
- * @PasswordConfirmationRequired
- * @NoAdminRequired
- *
* Create a new user
*
* @param string $userid ID of the user
*
* 200: User added successfully
*/
+ #[PasswordConfirmationRequired]
+ #[NoAdminRequired]
public function addUser(
string $userid,
string $password = '',
}
/**
- * @NoAdminRequired
* @NoSubAdminRequired
*
* Get the details of a user
*
* 200: User returned
*/
+ #[NoAdminRequired]
public function getUser(string $userId): DataResponse {
$includeScopes = false;
$currentUser = $this->userSession->getUser();
}
/**
- * @NoAdminRequired
* @NoSubAdminRequired
*
* Get the details of the current user
*
* 200: Current user returned
*/
+ #[NoAdminRequired]
public function getCurrentUser(): DataResponse {
$user = $this->userSession->getUser();
if ($user) {
}
/**
- * @NoAdminRequired
* @NoSubAdminRequired
*
* Get a list of fields that are editable for the current user
*
* 200: Editable fields returned
*/
+ #[NoAdminRequired]
public function getEditableFields(): DataResponse {
$currentLoggedInUser = $this->userSession->getUser();
if (!$currentLoggedInUser instanceof IUser) {
}
/**
- * @NoAdminRequired
* @NoSubAdminRequired
*
* Get a list of fields that are editable for a user
*
* 200: Editable fields for user returned
*/
+ #[NoAdminRequired]
public function getEditableFieldsForUser(string $userId): DataResponse {
$currentLoggedInUser = $this->userSession->getUser();
if (!$currentLoggedInUser instanceof IUser) {
}
/**
- * @NoAdminRequired
* @NoSubAdminRequired
- * @PasswordConfirmationRequired
- * @UserRateThrottle(limit=5, period=60)
*
* Update multiple values of the user's details
*
*
* 200: User values edited successfully
*/
+ #[PasswordConfirmationRequired]
+ #[NoAdminRequired]
+ #[UserRateLimit(limit: 5, period: 60)]
public function editUserMultiValue(
string $userId,
string $collectionName,
}
/**
- * @NoAdminRequired
* @NoSubAdminRequired
- * @PasswordConfirmationRequired
- * @UserRateThrottle(limit=50, period=600)
*
* Update a value of the user's details
*
*
* 200: User value edited successfully
*/
+ #[PasswordConfirmationRequired]
+ #[NoAdminRequired]
+ #[UserRateLimit(limit: 50, period: 60)]
public function editUser(string $userId, string $key, string $value): DataResponse {
$currentLoggedInUser = $this->userSession->getUser();
}
/**
- * @PasswordConfirmationRequired
- * @NoAdminRequired
- *
* Wipe all devices of a user
*
* @param string $userId ID of the user
*
* 200: Wiped all user devices successfully
*/
+ #[PasswordConfirmationRequired]
+ #[NoAdminRequired]
public function wipeUserDevices(string $userId): DataResponse {
/** @var IUser $currentLoggedInUser */
$currentLoggedInUser = $this->userSession->getUser();
}
/**
- * @PasswordConfirmationRequired
- * @NoAdminRequired
- *
* Delete a user
*
* @param string $userId ID of the user
*
* 200: User deleted successfully
*/
+ #[PasswordConfirmationRequired]
+ #[NoAdminRequired]
public function deleteUser(string $userId): DataResponse {
$currentLoggedInUser = $this->userSession->getUser();
}
/**
- * @PasswordConfirmationRequired
- * @NoAdminRequired
- *
* Disable a user
*
* @param string $userId ID of the user
*
* 200: User disabled successfully
*/
+ #[PasswordConfirmationRequired]
+ #[NoAdminRequired]
public function disableUser(string $userId): DataResponse {
return $this->setEnabled($userId, false);
}
/**
- * @PasswordConfirmationRequired
- * @NoAdminRequired
- *
* Enable a user
*
* @param string $userId ID of the user
*
* 200: User enabled successfully
*/
+ #[PasswordConfirmationRequired]
+ #[NoAdminRequired]
public function enableUser(string $userId): DataResponse {
return $this->setEnabled($userId, true);
}
}
/**
- * @NoAdminRequired
* @NoSubAdminRequired
*
* Get a list of groups the user belongs to
*
* 200: Users groups returned
*/
+ #[NoAdminRequired]
public function getUsersGroups(string $userId): DataResponse {
$loggedInUser = $this->userSession->getUser();
}
/**
- * @PasswordConfirmationRequired
- * @NoAdminRequired
- *
* Add a user to a group
*
* @param string $userId ID of the user
*
* 200: User added to group successfully
*/
+ #[PasswordConfirmationRequired]
+ #[NoAdminRequired]
public function addToGroup(string $userId, string $groupid = ''): DataResponse {
if ($groupid === '') {
throw new OCSException('', 101);
}
/**
- * @PasswordConfirmationRequired
- * @NoAdminRequired
- *
* Remove a user from a group
*
* @param string $userId ID of the user
*
* 200: User removed from group successfully
*/
+ #[PasswordConfirmationRequired]
+ #[NoAdminRequired]
public function removeFromGroup(string $userId, string $groupid): DataResponse {
$loggedInUser = $this->userSession->getUser();
}
/**
- * @PasswordConfirmationRequired
- *
* Make a user a subadmin of a group
*
* @param string $userId ID of the user
* 200: User added as group subadmin successfully
*/
#[AuthorizedAdminSetting(settings:Users::class)]
+ #[PasswordConfirmationRequired]
public function addSubAdmin(string $userId, string $groupid): DataResponse {
$group = $this->groupManager->get($groupid);
$user = $this->userManager->get($userId);
}
/**
- * @PasswordConfirmationRequired
- *
* Remove a user from the subadmins of a group
*
* @param string $userId ID of the user
* 200: User removed as group subadmin successfully
*/
#[AuthorizedAdminSetting(settings:Users::class)]
+ #[PasswordConfirmationRequired]
public function removeSubAdmin(string $userId, string $groupid): DataResponse {
$group = $this->groupManager->get($groupid);
$user = $this->userManager->get($userId);
}
/**
- * @NoAdminRequired
- * @PasswordConfirmationRequired
- *
* Resend the welcome message
*
* @param string $userId ID if the user
*
* 200: Resent welcome message successfully
*/
+ #[PasswordConfirmationRequired]
+ #[NoAdminRequired]
public function resendWelcomeMessage(string $userId): DataResponse {
$currentLoggedInUser = $this->userSession->getUser();
use OC\Security\Crypto;
use OCP\Accounts\IAccountManager;
use OCP\AppFramework\Controller;
+use OCP\AppFramework\Http\Attribute\BruteForceProtection;
+use OCP\AppFramework\Http\Attribute\NoAdminRequired;
+use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
use OCP\AppFramework\Http\Attribute\OpenAPI;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IL10N;
}
/**
- * @NoCSRFRequired
- * @NoAdminRequired
* @NoSubAdminRequired
*/
+ #[NoAdminRequired]
+ #[NoCSRFRequired]
public function showVerifyMail(string $token, string $userId, string $key): TemplateResponse {
if ($this->userSession->getUser()->getUID() !== $userId) {
// not a public page, hence getUser() must return an IUser
}
/**
- * @NoAdminRequired
* @NoSubAdminRequired
- * @BruteForceProtection(action=emailVerification)
*/
+ #[NoAdminRequired]
+ #[BruteForceProtection(action: 'emailVerification')]
public function verifyMail(string $token, string $userId, string $key): TemplateResponse {
$throttle = false;
try {