Skip to content

Commit 615eebd

Browse files
committed
merge main
2 parents e755be8 + f343088 commit 615eebd

File tree

13 files changed

+470
-81
lines changed

13 files changed

+470
-81
lines changed

backend/siarnaq/api/user/permissions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from django.conf import settings
12
from rest_framework.permissions import BasePermission
23

34

@@ -7,6 +8,9 @@ class IsEmailVerified(BasePermission):
78
message = "Please verify your email address to access this resource."
89

910
def has_permission(self, request, view):
11+
if not getattr(settings, "EMAIL_VERIFICATION_REQUIRED", True):
12+
return request.user and request.user.is_authenticated
13+
1014
if request.user and request.user.is_staff:
1115
return True
1216
return (

backend/siarnaq/api/user/signals.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,12 @@ def send_email_verification_token_email(
5757
When an email verification token is created, send an email to the user.
5858
"""
5959

60-
if not settings.EMAIL_ENABLED:
61-
logger.warn(
62-
"email_verification_disabled",
60+
if not settings.EMAIL_ENABLED or not settings.EMAIL_VERIFICATION_ENABLED:
61+
logger.info(
62+
"email_verification_skipped",
6363
message="Email verification emails are disabled.",
64+
user_id=email_verification_token.user.id,
65+
email=email_verification_token.user.email,
6466
)
6567
return
6668

backend/siarnaq/settings.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@ class Base(Configuration):
350350

351351
# Email Verification Configuration
352352
EMAIL_VERIFICATION_TOKEN_EXPIRY_TIME = 24 # Time in hours
353+
EMAIL_VERIFICATION_REQUIRED = False
354+
EMAIL_VERIFICATION_ENABLED = True
353355

354356

355357
class Local(Base):
@@ -543,6 +545,8 @@ class Production(Base):
543545

544546
EMAIL_ENABLED = True
545547
FRONTEND_ORIGIN = "https://play.battlecode.org"
548+
EMAIL_VERIFICATION_REQUIRED = True
549+
EMAIL_VERIFICATION_ENABLED = True
546550

547551
LOGGING: dict[str, Any] = {
548552
**_LOGGING_COMMON,

frontend/.env.development

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
VITE_THIS_URL=http://localhost:3000
22
VITE_BACKEND_URL=http://localhost:8000
33
VITE_REPLAY_URL=https://play.battlecode.org
4+
VITE_EMAIL_VERIFICATION_ENABLED=false

frontend/.env.production

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ VITE_THIS_URL=https://play.battlecode.org
22
VITE_BACKEND_URL=https://api.battlecode.org
33
VITE_REPLAY_URL=https://play.battlecode.org
44
GENERATE_SOURCEMAP=false
5+
VITE_EMAIL_VERIFICATION_ENABLED=true

frontend/src/components/EpisodeLayout.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,13 @@ const EpisodeLayout: React.FC = () => {
5555
};
5656

5757
const { user } = useCurrentUser();
58+
const emailVerificationEnabled =
59+
import.meta.env.VITE_EMAIL_VERIFICATION_ENABLED !== "false";
5860
const showVerificationBanner =
59-
user.isSuccess && !user.data.email_verified && !user.data.is_staff;
61+
emailVerificationEnabled &&
62+
user.isSuccess &&
63+
!user.data.email_verified &&
64+
!user.data.is_staff;
6065

6166
return (
6267
<div className="h-full min-h-screen bg-gray-200/80">

frontend/src/content/bc26.ts

Lines changed: 356 additions & 7 deletions
Large diffs are not rendered by default.

frontend/src/views/Account.tsx

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -219,28 +219,30 @@ const ProfileForm: React.FC<{
219219
{...register("email", { required: FIELD_REQUIRED_ERROR_MSG })}
220220
/>
221221
{/* Warning about email change and resend verification button */}
222-
<div className="col-span-2">
223-
<p className="text-xs text-gray-500">
224-
Note: Changing your email will require re-verification.
225-
</p>
226-
{user.data?.email_verified === false && (
227-
<div className="mt-2 flex items-center gap-2">
228-
<p className="text-xs text-yellow-700">
229-
Your email is not verified.
230-
</p>
231-
<Button
232-
label="Resend Verification Email"
233-
onClick={() => {
234-
resendEmailMutation.mutate(undefined);
235-
}}
236-
loading={resendEmailMutation.isPending}
237-
disabled={resendEmailMutation.isPending}
238-
variant="dark"
239-
className="text-xs"
240-
/>
241-
</div>
242-
)}
243-
</div>
222+
{import.meta.env.VITE_EMAIL_VERIFICATION_ENABLED !== "false" && (
223+
<div className="col-span-2">
224+
<p className="text-xs text-gray-500">
225+
Note: Changing your email will require re-verification.
226+
</p>
227+
{user.data?.email_verified === false && (
228+
<div className="mt-2 flex items-center gap-2">
229+
<p className="text-xs text-yellow-700">
230+
Your email is not verified.
231+
</p>
232+
<Button
233+
label="Resend Verification Email"
234+
onClick={() => {
235+
resendEmailMutation.mutate(undefined);
236+
}}
237+
loading={resendEmailMutation.isPending}
238+
disabled={resendEmailMutation.isPending}
239+
variant="dark"
240+
className="text-xs"
241+
/>
242+
</div>
243+
)}
244+
</div>
245+
)}
244246

245247
<Input
246248
required
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"episode": {
3+
"name": "bc26",
4+
"language": "java21",
5+
"scaffold": "https://github.com/battlecode/battlecode26-scaffold"
6+
},
7+
"metadata": {
8+
"report-url": "{{REPORT_PATH}}",
9+
"task-type": "compile"
10+
},
11+
"details": {
12+
"source": {
13+
"bucket": "local",
14+
"name": "/development/test-data/source/bc26-java21.zip"
15+
},
16+
"binary": {
17+
"bucket": "local",
18+
"name": "{{BINARY_PATH}}"
19+
},
20+
"team-name": "test",
21+
"package": "examplefuncsplayer"
22+
}
23+
}
Lines changed: 38 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,43 @@
11
{
2-
"episode": {
3-
"name": "bc25java",
4-
"language": "java21",
5-
"scaffold": "https://github.com/battlecode/battlecode25-scaffold"
2+
"episode": {
3+
"name": "bc26",
4+
"language": "java21",
5+
"scaffold": "https://github.com/battlecode/battlecode26-scaffold"
6+
},
7+
"metadata": {
8+
"report-url": "{{REPORT_PATH}}",
9+
"task-type": "execute"
10+
},
11+
"details": {
12+
"maps": ["DefaultSmall", "DefaultMedium", "DefaultLarge"],
13+
"replay": {
14+
"bucket": "local",
15+
"name": "{{REPLAY_PATH}}"
616
},
7-
"metadata": {
8-
"report-url": "{{REPORT_PATH}}",
9-
"task-type": "execute"
17+
"alternate-order": true,
18+
"a": {
19+
"source": {
20+
"bucket": "local",
21+
"name": "/development/test-data/source/bc26-java21.zip"
22+
},
23+
"binary": {
24+
"bucket": "local",
25+
"name": "/development/test-data/binary/bc26-java21.zip"
26+
},
27+
"team-name": "test1",
28+
"package": "examplefuncsplayer"
1029
},
11-
"details": {
12-
"maps": [
13-
"fix",
14-
"galaxy",
15-
"gridworld",
16-
"quack",
17-
"sierpinski"
18-
],
19-
"replay": {
20-
"bucket": "local",
21-
"name": "{{REPLAY_PATH}}"
22-
},
23-
"alternate-order": true,
24-
"a": {
25-
"source": {
26-
"bucket": "local",
27-
"name": "/development/test-data/source/java21.zip"
28-
},
29-
"binary": {
30-
"bucket": "local",
31-
"name": "/development/test-data/binary/java21.zip"
32-
},
33-
"team-name": "test1",
34-
"package": "examplefuncsplayer"
35-
},
36-
"b": {
37-
"source": {
38-
"bucket": "local",
39-
"name": "/development/test-data/source/java21.zip"
40-
},
41-
"binary": {
42-
"bucket": "local",
43-
"name": "/development/test-data/binary/java21.zip"
44-
},
45-
"team-name": "test2",
46-
"package": "examplefuncsplayer"
47-
}
30+
"b": {
31+
"source": {
32+
"bucket": "local",
33+
"name": "/development/test-data/source/bc26-java21.zip"
34+
},
35+
"binary": {
36+
"bucket": "local",
37+
"name": "/development/test-data/binary/bc26-java21.zip"
38+
},
39+
"team-name": "test2",
40+
"package": "examplefuncsplayer"
4841
}
42+
}
4943
}

0 commit comments

Comments
 (0)