Skip to content

Feature/atcoder verified voting#3319

Open
river0525 wants to merge 6 commits intostagingfrom
feature/atcoder-verified-voting
Open

Feature/atcoder verified voting#3319
river0525 wants to merge 6 commits intostagingfrom
feature/atcoder-verified-voting

Conversation

@river0525
Copy link
Copy Markdown
Collaborator

認証機能を分離したPRです。
サーバーの用意後、マージいたします。

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 27, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 15e73470-8adf-4b69-961c-dc3109901fe7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/atcoder-verified-voting

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

認証(AtCoderアカウント検証)を投票機能から独立させつつ、未認証ユーザーの投票をUI/サーバー両面で制限する変更です。投票導線からプロフィール編集(AtCoder認証タブ)へ誘導できるようにしています。

Changes:

  • 投票(詳細ページ/一覧のドロップダウン投票)を「ログイン + AtCoder認証済み」に制限
  • 未認証ユーザー向けに /users/edit?tab=atcoder への誘導UIを追加
  • ユーザー編集画面でAtCoder認証タブを復帰し、?tab=atcoder で初期表示タブを切替

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/routes/votes/[slug]/+page.svelte 未認証ログインユーザーへ認証誘導UIを追加
src/routes/votes/[slug]/+page.server.ts loadに isAtCoderVerified を追加
src/routes/users/edit/+page.svelte AtCoder認証タブ復帰、?tab=atcoder と form 結果でタブ自動オープン
src/routes/users/edit/+page.server.ts tab=atcoder をloadへ反映
src/routes/problems/+page.svelte TaskTableへ isAtCoderVerified を伝播
src/routes/problems/+page.server.ts loadに isAtCoderVerified を追加
src/lib/constants/navbar-links.ts EDIT_PROFILE_PAGE を追加
src/lib/components/AtCoderUserValidationForm.svelte バインド/状態管理を見直し、入力をローカルstate化
src/features/votes/components/VotableGrade.svelte 未認証時の投票UIを誘導に切替、isAtCoderVerified を追加
src/features/votes/actions/vote_actions.ts サーバー側で未認証投票を403で拒否
src/features/tasks/components/contest-table/TaskTableBodyCell.svelte isAtCoderVerified を VotableGradeへ伝播
src/features/tasks/components/contest-table/TaskTable.svelte isAtCoderVerified を子へ伝播

Comment on lines +121 to +132
{:else if data.isLoggedIn && !data.isAtCoderVerified}
<!-- ログイン済み・未認証 → 認証誘導 -->
<div
class="bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-700 rounded-lg p-4 mb-4"
>
<p class="text-yellow-800 dark:text-yellow-200 font-medium mb-2">
投票するにはAtCoderアカウントの認証が必要です。
</p>
<Button href={editProfileHref} color="yellow" size="sm">AtCoderアカウントを認証する</Button>
</div>
{:else if data.isLoggedIn}
<!-- 未投票・ログイン済み → 投票フォーム -->
<!-- 未投票・ログイン済み・認証済み → 投票フォーム -->
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new “logged in but unverified” branch only applies when data.myVote?.voted is false. If a user voted previously and later resets AtCoder verification, they will still hit the data.myVote?.voted branch and see the “投票を変更する” form, but the server action now rejects unverified users (403). Consider also gating the vote-change UI in the voted branch on data.isAtCoderVerified (or showing the same verification prompt there) to avoid a broken flow.

Copilot uses AI. Check for mistakes.
// Editable only in 'nothing' step; server is authoritative after each action.
// untrack: prop is the initial seed only — intentional one-time capture.
let editableAtcoderId = $state(untrack(() => atcoder_username));

Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

editableAtcoderId is seeded once from atcoder_username and never re-synced. After a successful reset (server clears atcoder_username and status becomes nothing), the input will still show the old AtCoder ID, diverging from server-authoritative state. Consider syncing editableAtcoderId when status becomes nothing (or when atcoder_username changes to an empty string) while still avoiding overwriting during user edits.

Suggested change
// Keep editableAtcoderId in sync with server after a reset:
// when the server clears atcoder_username and status returns to 'nothing',
// reset the local editable value as well.
$effect(() => {
if (status === 'nothing' && atcoder_username === '') {
editableAtcoderId = '';
}
});

Copilot uses AI. Check for mistakes.
Comment on lines +31 to +35
if (!locals.user?.is_validated) {
return fail(FORBIDDEN, {
message: 'AtCoderアカウントの認証が必要です。',
});
}
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The verification check conflates “user is not AtCoder-verified” with “locals.user is missing”. Since locals.user is populated in hooks.server.ts by looking up the DB user, a deleted/missing user could yield locals.user === undefined even when session is valid; returning 403 with an AtCoder-verification message would be misleading. Consider explicitly handling !locals.user (e.g., treat it as UNAUTHORIZED/INTERNAL_SERVER_ERROR) and only return FORBIDDEN when the user exists but is_validated is false.

Copilot uses AI. Check for mistakes.
Base automatically changed from feature/absolute_evaluation_voting to staging March 27, 2026 13:50
Copy link
Copy Markdown
Collaborator

@KATO-Hiro KATO-Hiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTMです

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants