diff --git a/exam/api/Register/Register.php b/exam/api/Register/Register.php index a45ccc5..78242cf 100644 --- a/exam/api/Register/Register.php +++ b/exam/api/Register/Register.php @@ -30,4 +30,21 @@ class Register extends Api } } } + + public function patch(): void + { + $code = Input::post("code"); + if (empty($code)) throw new Exception("Missing code", 400); + + try { + Response::json(User::confirm($code)); + } catch (Exception $err) { + switch ($err->getMessage()) { + case "NotFound": + throw new Exception("User not found", 404); + default: + throw $err; + } + } + } } diff --git a/exam/api/docs/api.yaml b/exam/api/docs/api.yaml index 6f0b20c..fa38819 100644 --- a/exam/api/docs/api.yaml +++ b/exam/api/docs/api.yaml @@ -119,6 +119,45 @@ paths: } tags: - Register + patch: + summary: Confirm register + description: Confirm a registration + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/ConfirmRequest" + responses: + 200: + description: Success + content: + application/json: + schema: + $ref: "#/components/schemas/BooleanResponse" + examples: + Success: + value: true + 400: + description: Missing fields + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResponse" + examples: + Missing fields: + value: { "message": "Missing code" } + 404: + description: User not found + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResponse" + examples: + User not found: + value: { "message": "User not found" } + tags: + - Register /user{id}: get: summary: Get user @@ -312,11 +351,20 @@ components: type: string password: type: string + ConfirmRequest: + type: object + required: + - code + properties: + code: + type: string + format: uuid4 securitySchemes: BasicAuth: type: apiKey name: token in: header + format: uuid4 tags: - name: Login/Logout - name: Register diff --git a/exam/api/docs/index.html b/exam/api/docs/index.html index 1541416..f2098b8 100644 --- a/exam/api/docs/index.html +++ b/exam/api/docs/index.html @@ -309,10 +309,10 @@ data-styled.g111[id="sc-eowDPD"]{content:"jcAXWA,"}/*!sc*/ .gsBSOU:focus{box-shadow:inset 0 2px 2px rgba(0, 0, 0, 0.45),0 2px 0 rgba(128, 128, 128, 0.25);}/*!sc*/ data-styled.g112[id="sc-iAlELC"]{content:"gsBSOU,"}/*!sc*/ .kpMtuJ{font-size:0.929em;line-height:20px;background-color:#186FAF;color:#ffffff;padding:3px 10px;text-transform:uppercase;font-family:Montserrat,sans-serif;margin:0;}/*!sc*/ -.ffmPnn{font-size:0.929em;line-height:20px;background-color:#2F8132;color:#ffffff;padding:3px 10px;text-transform:uppercase;font-family:Montserrat,sans-serif;margin:0;}/*!sc*/ .eUIOSr{font-size:0.929em;line-height:20px;background-color:#bf581d;color:#ffffff;padding:3px 10px;text-transform:uppercase;font-family:Montserrat,sans-serif;margin:0;}/*!sc*/ +.ffmPnn{font-size:0.929em;line-height:20px;background-color:#2F8132;color:#ffffff;padding:3px 10px;text-transform:uppercase;font-family:Montserrat,sans-serif;margin:0;}/*!sc*/ .ByFMv{font-size:0.929em;line-height:20px;background-color:#cc3333;color:#ffffff;padding:3px 10px;text-transform:uppercase;font-family:Montserrat,sans-serif;margin:0;}/*!sc*/ -data-styled.g113[id="sc-oeqTF"]{content:"kpMtuJ,ffmPnn,eUIOSr,ByFMv,"}/*!sc*/ +data-styled.g113[id="sc-oeqTF"]{content:"kpMtuJ,eUIOSr,ffmPnn,ByFMv,"}/*!sc*/ .bFiOkX{position:absolute;width:100%;z-index:100;background:#fafafa;color:#263238;box-sizing:border-box;box-shadow:0 0 6px rgba(0, 0, 0, 0.33);overflow:hidden;border-bottom-left-radius:4px;border-bottom-right-radius:4px;transition:all 0.25s ease;visibility:hidden;transform:translateY(-50%) scaleY(0);}/*!sc*/ data-styled.g114[id="sc-ezTrPE"]{content:"bFiOkX,"}/*!sc*/ .hdRKqQ{padding:10px;}/*!sc*/ @@ -366,7 +366,7 @@ data-styled.g137[id="sc-kvXgyf"]{content:"fBvPoH,"}/*!sc*/ -

Success

Request samples

Content type
application/json
{
  • "username": "string",
  • "email": "string",
  • "password": "string"
}

Response samples

Content type
application/json
true

User

Get user

Request samples

Content type
application/json
{
  • "username": "string",
  • "email": "string",
  • "password": "string"
}

Response samples

Content type
application/json
true

Confirm register

Confirm a registration

+
Request Body schema: application/json
required
code
required
string <uuid4>

Responses

Request samples

Content type
application/json
{
  • "code": "string"
}

Response samples

Content type
application/json
true

User

Get user

Get user by ID

Authorizations:
BasicAuth
path Parameters
id
required
integer <int14>

User ID

@@ -436,7 +444,7 @@ data-styled.g137[id="sc-kvXgyf"]{content:"fBvPoH,"}/*!sc*/ " class="sc-euGpHm sc-exayXG fwfkcU kqJXdD sc-dHrNzZ dRdjww">

User not found

Response samples

Content type
application/json
true