Skip to content

Commit d21ee3d

Browse files
authored
Merge pull request #1106 from nextcloud/backport/1100/stable4.6
[stable4.6] fix: add check for user for signing terms
2 parents a9d6252 + 47951b1 commit d21ee3d

File tree

3 files changed

+62
-1
lines changed

3 files changed

+62
-1
lines changed

lib/Controller/SigningController.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,18 @@ public function signTerms(int $termId): DataResponse {
102102
/**
103103
* As a guest sign the terms
104104
*
105-
* @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
105+
* @return DataResponse<Http::STATUS_OK|Http::STATUS_NOT_ACCEPTABLE, list<empty>, array{}>
106106
*
107107
* 200: Signed successfully
108+
* 406: The user is already authenticated and therefore not allowed to sign the terms through this endpoint
108109
*/
109110
#[PublicPage]
110111
#[UseSession]
111112
public function signTermsPublic(): DataResponse {
113+
if ($this->userId !== null) {
114+
return new DataResponse([], Http::STATUS_NOT_ACCEPTABLE);
115+
}
116+
112117
$uuid = $this->config->getAppValue(Application::APPNAME, 'term_uuid', '');
113118
$this->session->set('term_uuid', $uuid);
114119

openapi-full.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,34 @@
542542
}
543543
}
544544
}
545+
},
546+
"406": {
547+
"description": "The user is already authenticated and therefore not allowed to sign the terms through this endpoint",
548+
"content": {
549+
"application/json": {
550+
"schema": {
551+
"type": "object",
552+
"required": [
553+
"ocs"
554+
],
555+
"properties": {
556+
"ocs": {
557+
"type": "object",
558+
"required": [
559+
"meta",
560+
"data"
561+
],
562+
"properties": {
563+
"meta": {
564+
"$ref": "#/components/schemas/OCSMeta"
565+
},
566+
"data": {}
567+
}
568+
}
569+
}
570+
}
571+
}
572+
}
545573
}
546574
}
547575
}

openapi.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,34 @@
323323
}
324324
}
325325
}
326+
},
327+
"406": {
328+
"description": "The user is already authenticated and therefore not allowed to sign the terms through this endpoint",
329+
"content": {
330+
"application/json": {
331+
"schema": {
332+
"type": "object",
333+
"required": [
334+
"ocs"
335+
],
336+
"properties": {
337+
"ocs": {
338+
"type": "object",
339+
"required": [
340+
"meta",
341+
"data"
342+
],
343+
"properties": {
344+
"meta": {
345+
"$ref": "#/components/schemas/OCSMeta"
346+
},
347+
"data": {}
348+
}
349+
}
350+
}
351+
}
352+
}
353+
}
326354
}
327355
}
328356
}

0 commit comments

Comments
 (0)