Skip to content

Commit 37a5f65

Browse files
committed
Added doc for email reset
1 parent 68f30ea commit 37a5f65

File tree

2 files changed

+78
-4
lines changed

2 files changed

+78
-4
lines changed

backend/PyMatcha/routes/api/auth/email.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def confirm_email(token):
6969
u.confirmed_on = datetime.datetime.utcnow()
7070
u.save()
7171
current_app.logger.debug("/auth/confirm -> User {} confirmed.".format(u.id))
72-
return Success("Confirmation successfull")
72+
return Success("Confirmation successful")
7373

7474

7575
@auth_email_bp.route("/auth/confirm/new", methods=["POST"])
@@ -82,16 +82,14 @@ def request_new_email_conf():
8282
u = get_user(email)
8383
except NotFoundError:
8484
current_app.logger.debug("/auth/confirm/new -> User not found")
85-
pass
8685
else:
8786
if u.is_confirmed:
8887
current_app.logger.debug("/auth/confirm/new -> User found, Already confirmed.")
89-
return Success("User already confirmed")
9088
else:
9189
current_app.logger.debug("/auth/confirm/new -> User found, sending new confirmation email")
9290
token = generate_confirmation_token(email=email, token_type="confirm")
9391
link = FRONTEND_EMAIL_CONFIRMATION_URL + token
9492
rendered_html = render_template("confirm_email.html", link=link)
9593
send_mail_html.delay(dest=data["email"], subject="Confirm your email on PyMatcha", html=rendered_html)
9694
current_app.logger.debug("/auth/confirm/new -> New confirmation email sent if user exists in database")
97-
return Success("New confirmation email sent if user exists in database")
95+
return Success("New confirmation email sent if user exists in database and isn't already confirmed")

backend/schemas/swagger.yaml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,82 @@ paths:
241241
message:
242242
type: string
243243
example: Refresh token revoked
244+
/auth/confirm/{token}:
245+
post:
246+
summary: Confirm a user with a token
247+
operationId: confirmUser
248+
tags:
249+
- Authentication
250+
parameters:
251+
- name: token
252+
in: path
253+
required: true
254+
description: The confirmation token
255+
schema:
256+
type: string
257+
responses:
258+
"404":
259+
$ref: '#/components/responses/NotFound'
260+
"400":
261+
$ref: '#/components/responses/BadRequest'
262+
"200":
263+
description: Returned user to view
264+
content:
265+
application/json:
266+
schema:
267+
type: object
268+
properties:
269+
success:
270+
type: boolean
271+
description: If the request is a success
272+
example: true
273+
code:
274+
type: integer
275+
description: The status code
276+
example: 200
277+
message:
278+
type: string
279+
example: Confirmation successful
280+
/auth/confirm/new:
281+
post:
282+
summary: Request a new confirmation email
283+
description: Will always return a success, even if the user is not found or already confirmed
284+
operationId: newConfirmEmail
285+
tags:
286+
- Authentication
287+
requestBody:
288+
description: Parameters to request new confirmation email
289+
required: true
290+
content:
291+
application/json:
292+
schema:
293+
type: object
294+
properties:
295+
email:
296+
required: true
297+
type: string
298+
example: foo@example.org
299+
responses:
300+
"400":
301+
$ref: '#/components/responses/BadRequest'
302+
"200":
303+
description: Returned user to view
304+
content:
305+
application/json:
306+
schema:
307+
type: object
308+
properties:
309+
success:
310+
type: boolean
311+
description: If the request is a success
312+
example: true
313+
code:
314+
type: integer
315+
description: The status code
316+
example: 200
317+
message:
318+
type: string
319+
example: New confirmation email sent if user exists in database and isn't already confirmed
244320
/profile/complete:
245321
post:
246322
tags:

0 commit comments

Comments
 (0)