Skip to content

Commit acbced4

Browse files
committed
Added password reset
1 parent d758ad3 commit acbced4

File tree

2 files changed

+82
-2
lines changed

2 files changed

+82
-2
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ def forgot_password():
5555
pass
5656
else:
5757
token = generate_confirmation_token(email=data["email"], token_type="reset")
58-
link = os.getenv("APP_URL") + "/auth/password/forgot/" + token
58+
# link = os.getenv("APP_URL") + "/auth/password/forgot/" + token
59+
link = f"{os.getenv('FRONT_URL')}/accounts/password/reset?token={token}"
5960
rendered_html = render_template("password_reset.html", link=link)
6061
current_app.logger.debug("/auth/password/forgot -> Sending worker request to send email")
6162
send_mail_html.delay(dest=data["email"], subject="Reset your password on PyMatcha", html=rendered_html)

backend/schemas/swagger.yaml

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ paths:
279279
type: string
280280
example: Profile completed !
281281
/profile/edit:
282-
post:
282+
put:
283283
tags:
284284
- Profile
285285
summary: Edit user profile
@@ -880,6 +880,85 @@ paths:
880880
type: array
881881
items:
882882
$ref: '#/components/schemas/OnlineUser'
883+
/auth/password/forgot:
884+
post:
885+
summary: Request a password reset
886+
description: Will always return a success, no matter the email passed. Emails will be sent only to valid email adresses in the database
887+
operationId: requestPasswordReset
888+
tags:
889+
- Authentication
890+
requestBody:
891+
description: Parameters to request password reset
892+
required: true
893+
content:
894+
application/json:
895+
schema:
896+
type: object
897+
properties:
898+
email:
899+
type: string
900+
required: true
901+
example: foo@example.org
902+
responses:
903+
"200":
904+
description: Success
905+
content:
906+
application/json:
907+
schema:
908+
type: object
909+
properties:
910+
code:
911+
type: string
912+
example: 200
913+
success:
914+
type: boolean
915+
example: true
916+
message:
917+
type: string
918+
example: Password reset mail sent successfully if user exists in DB
919+
/auth/password/reset:
920+
post:
921+
summary: Reset a password
922+
operationId: passwordReset
923+
tags:
924+
- Authentication
925+
requestBody:
926+
description: Parameters to request password reset
927+
required: true
928+
content:
929+
application/json:
930+
schema:
931+
type: object
932+
properties:
933+
email:
934+
type: string
935+
required: true
936+
example: foo@example.org
937+
password:
938+
type: string
939+
required: true
940+
example: dolphin2
941+
responses:
942+
"404":
943+
$ref: '#/components/responses/NotFound'
944+
"400":
945+
$ref: '#/components/responses/BadRequest'
946+
"200":
947+
description: Success
948+
content:
949+
application/json:
950+
schema:
951+
type: object
952+
properties:
953+
code:
954+
type: string
955+
example: 200
956+
success:
957+
type: boolean
958+
example: true
959+
message:
960+
type: string
961+
example: Password reset successful.
883962

884963

885964
servers:

0 commit comments

Comments
 (0)