-
Notifications
You must be signed in to change notification settings - Fork 94
feat(judge): dedicated judge portal, organizer invitations, completeness gate UX #550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,6 +5,8 @@ import { useRouter, useSearchParams } from 'next/navigation'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { useEffect } from 'react'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { toast } from 'sonner'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const POST_VERIFY_KEY = 'boundless:postVerifyCallbackUrl'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const VerifyEmail = () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const router = useRouter(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const searchParams = useSearchParams(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -16,7 +18,21 @@ const VerifyEmail = () => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fetchOptions: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onSuccess: () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| toast.success('Email verified successfully'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| router.push('/'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Honor a post-verify destination stashed by the signup flow | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // (e.g. a judge invitation page). Same-origin paths only. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let target = '/'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (typeof window !== 'undefined') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const stashed = window.localStorage.getItem(POST_VERIFY_KEY); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (stashed && stashed.startsWith('/')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| target = stashed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| window.localStorage.removeItem(POST_VERIFY_KEY); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // ignore storage errors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| router.push(target); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+21
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Insufficient open redirect protection. The validation 🔒 Recommended fix for robust path validation let target = '/';
if (typeof window !== 'undefined') {
try {
const stashed = window.localStorage.getItem(POST_VERIFY_KEY);
- if (stashed && stashed.startsWith('/')) {
+ if (stashed && stashed.startsWith('/') && !stashed.startsWith('//')) {
target = stashed;
}
window.localStorage.removeItem(POST_VERIFY_KEY);Or use a more robust URL validation: let target = '/';
if (typeof window !== 'undefined') {
try {
const stashed = window.localStorage.getItem(POST_VERIFY_KEY);
- if (stashed && stashed.startsWith('/')) {
- target = stashed;
- }
+ if (stashed) {
+ try {
+ const url = new URL(stashed, window.location.origin);
+ if (url.origin === window.location.origin) {
+ target = url.pathname + url.search + url.hash;
+ }
+ } catch {
+ // Invalid URL, ignore
+ }
+ }
window.localStorage.removeItem(POST_VERIFY_KEY);📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onError: () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| toast.error('Failed to verify email'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid 'any' type; add viewerRole to Hackathon type.
The code uses
(hackathon as any)?.viewerRolewhich bypasses TypeScript's type safety. TheviewerRoleproperty should be added to theHackathontype definition inlib/api/hackathons.tsto maintain type safety.🔧 Recommended fix
Add
viewerRoleto theHackathontype inlib/api/hackathons.ts:export type Hackathon = { id: string; name: string; // ... other fields + viewerRole?: 'organizer' | 'judge' | 'participant' | 'guest'; // ... rest of fields };Then remove the
anyassertion:As per coding guidelines: "Do not use 'any' type; always search for proper Trustless Work entity types."
🤖 Prompt for AI Agents