Skip to content

Commit 4f9ffa8

Browse files
committed
refactor(weather_status): Replace security annotations with respective attributes
Signed-off-by: provokateurin <[email protected]>
1 parent 212a621 commit 4f9ffa8

1 file changed

Lines changed: 8 additions & 14 deletions

File tree

apps/weather_status/lib/Controller/WeatherStatusController.php

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use OCA\WeatherStatus\ResponseDefinitions;
1212
use OCA\WeatherStatus\Service\WeatherStatusService;
1313
use OCP\AppFramework\Http;
14+
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
1415
use OCP\AppFramework\Http\DataResponse;
1516
use OCP\AppFramework\OCSController;
1617
use OCP\IRequest;
@@ -33,21 +34,18 @@ public function __construct(
3334
}
3435

3536
/**
36-
* @NoAdminRequired
37-
*
3837
* Try to use the address set in user personal settings as weather location
3938
*
4039
* @return DataResponse<Http::STATUS_OK, WeatherStatusLocationWithSuccess, array{}>
4140
*
4241
* 200: Address updated
4342
*/
43+
#[NoAdminRequired]
4444
public function usePersonalAddress(): DataResponse {
4545
return new DataResponse($this->service->usePersonalAddress());
4646
}
4747

4848
/**
49-
* @NoAdminRequired
50-
*
5149
* Change the weather status mode. There are currently 2 modes:
5250
* - ask the browser
5351
* - use the user defined address
@@ -57,13 +55,12 @@ public function usePersonalAddress(): DataResponse {
5755
*
5856
* 200: Weather status mode updated
5957
*/
58+
#[NoAdminRequired]
6059
public function setMode(int $mode): DataResponse {
6160
return new DataResponse($this->service->setMode($mode));
6261
}
6362

6463
/**
65-
* @NoAdminRequired
66-
*
6764
* Set address and resolve it to get coordinates
6865
* or directly set coordinates and get address with reverse geocoding
6966
*
@@ -74,35 +71,34 @@ public function setMode(int $mode): DataResponse {
7471
*
7572
* 200: Location updated
7673
*/
74+
#[NoAdminRequired]
7775
public function setLocation(?string $address, ?float $lat, ?float $lon): DataResponse {
7876
$currentWeather = $this->service->setLocation($address, $lat, $lon);
7977
return new DataResponse($currentWeather);
8078
}
8179

8280
/**
83-
* @NoAdminRequired
84-
*
8581
* Get stored user location
8682
*
8783
* @return DataResponse<Http::STATUS_OK, WeatherStatusLocationWithMode, array{}>
8884
*
8985
* 200: Location returned
9086
*/
87+
#[NoAdminRequired]
9188
public function getLocation(): DataResponse {
9289
$location = $this->service->getLocation();
9390
return new DataResponse($location);
9491
}
9592

9693
/**
97-
* @NoAdminRequired
98-
*
9994
* Get forecast for current location
10095
*
10196
* @return DataResponse<Http::STATUS_OK, WeatherStatusForecast[]|array{error: string}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, WeatherStatusSuccess, array{}>
10297
*
10398
* 200: Forecast returned
10499
* 404: Forecast not found
105100
*/
101+
#[NoAdminRequired]
106102
public function getForecast(): DataResponse {
107103
$forecast = $this->service->getForecast();
108104
if (isset($forecast['success']) && $forecast['success'] === false) {
@@ -113,28 +109,26 @@ public function getForecast(): DataResponse {
113109
}
114110

115111
/**
116-
* @NoAdminRequired
117-
*
118112
* Get favorites list
119113
*
120114
* @return DataResponse<Http::STATUS_OK, string[], array{}>
121115
*
122116
* 200: Favorites returned
123117
*/
118+
#[NoAdminRequired]
124119
public function getFavorites(): DataResponse {
125120
return new DataResponse($this->service->getFavorites());
126121
}
127122

128123
/**
129-
* @NoAdminRequired
130-
*
131124
* Set favorites list
132125
*
133126
* @param string[] $favorites Favorite addresses
134127
* @return DataResponse<Http::STATUS_OK, WeatherStatusSuccess, array{}>
135128
*
136129
* 200: Favorites updated
137130
*/
131+
#[NoAdminRequired]
138132
public function setFavorites(array $favorites): DataResponse {
139133
return new DataResponse($this->service->setFavorites($favorites));
140134
}

0 commit comments

Comments
 (0)