Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions apps/settings/lib/Controller/AuthSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ public function __construct(string $appName,
* @return JSONResponse
*/
public function create($name) {
if ($this->checkAppToken()) {
return $this->getServiceNotAvailableResponse();
}

try {
$sessionId = $this->session->getId();
} catch (SessionNotAvailableException $ex) {
Expand Down Expand Up @@ -181,6 +185,10 @@ private function generateRandomDeviceToken() {
return implode('-', $groups);
}

private function checkAppToken(): bool {
return $this->session->exists('app_password');
}

/**
* @NoAdminRequired
* @NoSubAdminRequired
Expand All @@ -189,6 +197,10 @@ private function generateRandomDeviceToken() {
* @return array|JSONResponse
*/
public function destroy($id) {
if ($this->checkAppToken()) {
return new JSONResponse([], Http::STATUS_BAD_REQUEST);
}

try {
$token = $this->findTokenByIdAndUser($id);
} catch (WipeTokenException $e) {
Expand All @@ -213,6 +225,10 @@ public function destroy($id) {
* @return array|JSONResponse
*/
public function update($id, array $scope, string $name) {
if ($this->checkAppToken()) {
return new JSONResponse([], Http::STATUS_BAD_REQUEST);
}

try {
$token = $this->findTokenByIdAndUser($id);
} catch (InvalidTokenException $e) {
Expand Down Expand Up @@ -287,6 +303,10 @@ private function findTokenByIdAndUser(int $id): IToken {
* @throws \OC\Authentication\Exceptions\ExpiredTokenException
*/
public function wipe(int $id): JSONResponse {
if ($this->checkAppToken()) {
return new JSONResponse([], Http::STATUS_BAD_REQUEST);
}

try {
$token = $this->findTokenByIdAndUser($id);
} catch (InvalidTokenException $e) {
Expand Down