Skip to content

Commit bceb845

Browse files
committed
linter pt 2
1 parent 73af85a commit bceb845

File tree

5 files changed

+32
-34
lines changed

5 files changed

+32
-34
lines changed

backend/app/services/implementations/auth_service.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ def reset_password(self, email: str) -> None:
5454
handle_code_in_app=True,
5555
)
5656

57-
reset_link = firebase_admin.auth.generate_password_reset_link(
58-
email, action_code_settings
59-
)
57+
reset_link = firebase_admin.auth.generate_password_reset_link(email, action_code_settings)
6058

6159
# Send via SES
6260
email_sent = self.ses_email_service.send_password_reset_email(email, reset_link)
@@ -83,9 +81,7 @@ def send_email_verification_link(self, email: str) -> None:
8381
)
8482

8583
# Generate the verification link
86-
verification_link = firebase_admin.auth.generate_email_verification_link(
87-
email, action_code_settings
88-
)
84+
verification_link = firebase_admin.auth.generate_email_verification_link(email, action_code_settings)
8985

9086
# Send the verification email via SES (works with any email address)
9187
email_sent = self.ses_email_service.send_verification_email(email, verification_link)
@@ -94,7 +90,9 @@ def send_email_verification_link(self, email: str) -> None:
9490
self.logger.info(f"Email verification sent successfully to {email}")
9591
else:
9692
# If SES fails, we can still provide the link for manual verification
97-
self.logger.warning(f"Failed to send verification email to {email}, but link was generated: {verification_link}")
93+
self.logger.warning(
94+
f"Failed to send verification email to {email}, but link was generated: {verification_link}"
95+
)
9896
# For development/testing, you could log the link or store it temporarily
9997
# In production, you might want to implement a fallback mechanism
10098

backend/app/utilities/ses_email_service.py

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ def verify_email_address(self, email: str) -> bool:
4545
self.logger.info(f"Email verification request sent to {email}")
4646
return True
4747
except ClientError as e:
48-
error_code = e.response['Error']['Code']
49-
if error_code == 'AlreadyExists':
48+
error_code = e.response["Error"]["Code"]
49+
if error_code == "AlreadyExists":
5050
self.logger.info(f"Email {email} is already verified")
5151
return True
5252
else:
@@ -56,12 +56,12 @@ def verify_email_address(self, email: str) -> bool:
5656
def send_templated_email(self, to_email: str, template_name: str, template_data: Dict[str, Any]) -> bool:
5757
"""
5858
Send a templated email using SES
59-
59+
6060
Args:
6161
to_email: Recipient email address
6262
template_name: Name of the SES template
6363
template_data: Data to populate template variables
64-
64+
6565
Returns:
6666
bool: True if email sent successfully, False otherwise
6767
"""
@@ -72,23 +72,25 @@ def send_templated_email(self, to_email: str, template_name: str, template_data:
7272
try:
7373
response = self.ses_client.send_templated_email(
7474
Source=self.source_email,
75-
Destination={'ToAddresses': [to_email]},
75+
Destination={"ToAddresses": [to_email]},
7676
Template=template_name,
77-
TemplateData=json.dumps(template_data)
77+
TemplateData=json.dumps(template_data),
7878
)
7979

8080
self.logger.info(f"Email sent successfully to {to_email}. MessageId: {response['MessageId']}")
8181
return True
8282

8383
except ClientError as e:
84-
error_code = e.response['Error']['Code']
85-
error_message = e.response['Error']['Message']
84+
error_code = e.response["Error"]["Code"]
85+
error_message = e.response["Error"]["Message"]
8686

87-
if error_code == 'MessageRejected' and 'not verified' in error_message:
87+
if error_code == "MessageRejected" and "not verified" in error_message:
8888
# Try to verify the email address automatically
8989
self.logger.info(f"Email {to_email} not verified. Attempting to verify...")
9090
if self.verify_email_address(to_email):
91-
self.logger.info(f"Email verification request sent to {to_email}. Please check your email and verify.")
91+
self.logger.info(
92+
f"Email verification request sent to {to_email}. Please check your email and verify."
93+
)
9294
else:
9395
self.logger.error(f"Failed to send verification request for {to_email}")
9496
return False
@@ -102,33 +104,29 @@ def send_templated_email(self, to_email: str, template_name: str, template_data:
102104
def send_verification_email(self, to_email: str, verification_link: str) -> bool:
103105
"""
104106
Send email verification email
105-
107+
106108
Args:
107109
to_email: Recipient email address
108110
verification_link: Firebase verification link
109-
111+
110112
Returns:
111113
bool: True if email sent successfully, False otherwise
112114
"""
113-
template_data = {
114-
"verification_link": verification_link
115-
}
115+
template_data = {"verification_link": verification_link}
116116

117117
return self.send_templated_email(to_email, "EmailVerification", template_data)
118118

119119
def send_password_reset_email(self, to_email: str, reset_link: str) -> bool:
120120
"""
121121
Send password reset email
122-
122+
123123
Args:
124124
to_email: Recipient email address
125125
reset_link: Firebase password reset link
126-
126+
127127
Returns:
128128
bool: True if email sent successfully, False otherwise
129129
"""
130-
template_data = {
131-
"reset_link": reset_link
132-
}
130+
template_data = {"reset_link": reset_link}
133131

134132
return self.send_templated_email(to_email, "PasswordReset", template_data)

frontend/src/hooks/useEmailVerification.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ export const useEmailVerification = () => {
1212
setSuccess(false);
1313

1414
try {
15-
await baseAPIClient.post(`/auth/send-email-verification/${encodeURIComponent(email)}`, {}, {
16-
withCredentials: true,
17-
});
15+
await baseAPIClient.post(
16+
`/auth/send-email-verification/${encodeURIComponent(email)}`,
17+
{},
18+
{
19+
withCredentials: true,
20+
},
21+
);
1822
setSuccess(true);
1923
} catch (err) {
2024
setError('An error occurred while sending verification email');

frontend/src/pages/admin-verify.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ export default function AdminVerifyPage() {
2121
text: '',
2222
});
2323

24-
const { sendVerificationEmail, isLoading, error, success } =
25-
useEmailVerification();
24+
const { sendVerificationEmail, isLoading, error, success } = useEmailVerification();
2625
const [autoSent, setAutoSent] = useState<boolean>(false);
2726

2827
useEffect(() => {

frontend/src/pages/verify.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ export default function VerifyPage() {
1818
text: '',
1919
});
2020

21-
const { sendVerificationEmail, isLoading, error, success } =
22-
useEmailVerification();
21+
const { sendVerificationEmail, isLoading, error, success } = useEmailVerification();
2322
const [autoSent, setAutoSent] = useState<boolean>(false);
2423

2524
useEffect(() => {

0 commit comments

Comments
 (0)