@@ -45,25 +45,25 @@ async def request_password_reset(self, req: PasswordResetRequest) -> UserSuccess
4545 self .logger .info (
4646 {
4747 "activity_type" : ACTIVITY_TYPES ["REQUEST_RESET_PASSWORD" ],
48- "message" : "User is not active" ,
48+ "message" : MESSAGES [ "PASSWORD_RESET" ][ "INACTIVE" ] ,
4949 "metadata" : {"user" : {"email" : req .email }},
5050 }
5151 )
5252 return {
5353 "is_success" : False ,
54- "message" : "You can only reset the password of an active account!" ,
54+ "message" : MESSAGES [ "PASSWORD_RESET" ][ "INACTIVE" ] ,
5555 }
5656 elif not existing_user .is_enabled :
5757 self .logger .info (
5858 {
5959 "activity_type" : ACTIVITY_TYPES ["REQUEST_RESET_PASSWORD" ],
60- "message" : "User is not enabled" ,
60+ "message" : MESSAGES [ "PASSWORD_RESET" ][ "DISABLED" ] ,
6161 "metadata" : {"user" : {"email" : req .email }},
6262 }
6363 )
6464 return {
6565 "is_success" : False ,
66- "message" : "You can only reset the password of an enabled account!" ,
66+ "message" : MESSAGES [ "PASSWORD_RESET" ][ "DISABLED" ] ,
6767 }
6868 password_reset_token = self .utility_service .generate_uuid ()
6969 uuid = password_reset_token ["uuid" ]
@@ -75,7 +75,7 @@ async def request_password_reset(self, req: PasswordResetRequest) -> UserSuccess
7575 self .logger .info (
7676 {
7777 "activity_type" : ACTIVITY_TYPES ["REQUEST_RESET_PASSWORD" ],
78- "message" : "Password reset token set" ,
78+ "message" : DYNAMIC_MESSAGES [ "PASSWORD_RESET" ][ "EMAIL_SENT" ]( req . email ) ,
7979 "metadata" : {
8080 "user" : {"email" : req .email },
8181 "reset_token" : existing_user .password_reset_token ,
@@ -95,7 +95,7 @@ async def confirm_password_reset(
9595 self .logger .warn (
9696 {
9797 "activity_type" : "Confirm password reset" ,
98- "message" : "User doesn't exist" ,
98+ "message" : MESSAGES [ "USER" ][ "DOESNT_EXIST" ] ,
9999 "metadata" : {"token" : req .reset_token },
100100 }
101101 )
@@ -107,25 +107,25 @@ async def confirm_password_reset(
107107 self .logger .info (
108108 {
109109 "activity_type" : "Confirm password reset" ,
110- "message" : "User is not active" ,
110+ "message" : MESSAGES [ "PASSWORD_RESET" ][ "INACTIVE" ] ,
111111 "metadata" : {"token" : req .reset_token },
112112 }
113113 )
114114 return {
115115 "is_success" : False ,
116- "message" : "You can only reset the password of an active account!" ,
116+ "message" : MESSAGES [ "PASSWORD_RESET" ][ "INACTIVE" ] ,
117117 }
118118 elif not existing_user .is_enabled :
119119 self .logger .info (
120120 {
121121 "activity_type" : "Confirm password reset" ,
122- "message" : "User is not enabled" ,
122+ "message" : MESSAGES [ "PASSWORD_RESET" ][ "DISABLED" ] ,
123123 "metadata" : {"token" : req .reset_token },
124124 }
125125 )
126126 return {
127127 "is_success" : False ,
128- "message" : "You can only reset the password of an enabled account!" ,
128+ "message" : MESSAGES [ "PASSWORD_RESET" ][ "DISABLED" ] ,
129129 }
130130
131131 if existing_user .token_expires_at < timezone .now ():
0 commit comments