Skip to content

Add active-user gating for login and exam assignment - #158

Merged
kristofer merged 4 commits into
mainfrom
copilot/add-user-edit-panel-flag
Jun 9, 2026
Merged

kristofer merged 4 commits into
mainfrom
copilot/add-user-edit-panel-flag

Conversation

Copilot AI commented Jun 9, 2026 •

Copy link
Copy Markdown

This change adds a user-level isActive control and wires it into the exam flow. Active students now appear in the Assign Exam panel, inactive users cannot log in, and admins can open exam URLs while logged in to inspect their contents.

  • User activation state

    • Adds users.is_active via migration.
    • Extends the user model and admin user edit form/table to view and update isActive.
    • Preserves existing behavior by defaulting new users to active.
  • Auth and access control

    • Rejects login for inactive users.
    • Requires admin users to be active to access admin/instructor routes.
    • Allows logged-in admins to open exam URLs without being individually assigned.
  • Exam assignment flow

    • Filters instructor student listings to active, non-admin users only.
    • Prevents exam assignment to inactive users and admin accounts.
    • Fixes the Assign Exam UI to read the student identifier returned by the metrics API, which is why the student list was rendering empty.
  • UI behavior

    • Updates the admin users page to expose the new activation flag.
    • Updates the exam assignment panel empty state to reflect that only active students are eligible.
  • Focused coverage

    • Adds tests for inactive-user login rejection, active-student filtering, inactive-student assignment rejection, and admin exam preview access.
if !user.IsAdmin {
	assignedExams, err := h.db.GetAssignedExamsForUser(userID)
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	assigned := false
	for _, ae := range assignedExams {
		if ae.ExamID == exam.ID {
			assigned = true
			break
		}
	}
	if !assigned {
		http.Error(w, "Exam not assigned to this user", http.StatusForbidden)
		return
	}
}

Copilot AI linked an issue Jun 9, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add isActive flag to user edit panel and update exam assignment Add active-user gating for login and exam assignment Jun 9, 2026
Copilot AI requested a review from kristofer June 9, 2026 16:53
@kristofer
kristofer marked this pull request as ready for review June 9, 2026 19:20
@kristofer
kristofer merged commit 336218a into main Jun 9, 2026
2 checks passed
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.

two new user features.

2 participants