Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions discord/api/onboarding_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,19 @@ var validInitialRoles = map[string]bool{
"guest": true,
}

// isUCSBEmail reports whether the email's domain is ucsb.edu (case-insensitive).
func isUCSBEmail(email string) bool {
var studentEmailDomains = map[string]bool{
"ucsb.edu": true,
"pipeline.sbcc.edu": true,
}

// isStudentEmail reports whether the email's domain is a recognized student
// domain (ucsb.edu or pipeline.sbcc.edu), case-insensitive.
func isStudentEmail(email string) bool {
parts := strings.SplitN(email, "@", 2)
return len(parts) == 2 && strings.EqualFold(parts[1], "ucsb.edu")
if len(parts) != 2 {
return false
}
return studentEmailDomains[strings.ToLower(parts[1])]
}

func ConsumeOnboardingToken(c *gin.Context) {
Expand All @@ -92,9 +101,9 @@ func ConsumeOnboardingToken(c *gin.Context) {

switch req.InitialRole {
case "member":
if !isUCSBEmail(req.Email) {
if !isStudentEmail(req.Email) {
c.JSON(http.StatusBadRequest, gin.H{
"error": "current members must sign up with their @ucsb.edu email",
"error": "current members must sign up with their @ucsb.edu or @pipeline.sbcc.edu email",
})
return
}
Expand All @@ -105,9 +114,9 @@ func ConsumeOnboardingToken(c *gin.Context) {
return
}
case "alumni":
if isUCSBEmail(req.Email) {
if isStudentEmail(req.Email) {
c.JSON(http.StatusBadRequest, gin.H{
"error": "alumni must sign up with a personal email since @ucsb.edu addresses expire after graduation",
"error": "alumni must sign up with a personal email since @ucsb.edu and @pipeline.sbcc.edu addresses expire after graduation",
})
return
}
Expand Down
27 changes: 15 additions & 12 deletions web/src/pages/onboarding/OnboardingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const HOLD_MS = 250

const STEP_SLIDE_PX = 24

const STUDENT_DOMAIN = "ucsb.edu"
const STUDENT_DOMAINS = new Set(["ucsb.edu", "pipeline.sbcc.edu"])

const stepVariants: Variants = {
enter: (dir: "forward" | "back") => ({
Expand Down Expand Up @@ -172,12 +172,13 @@ export default function OnboardingPage() {

const emailDomain = data.email.split("@")[1]?.toLowerCase() ?? ""
const hasFullDomain = emailDomain.includes(".")
const memberNeedsUcsbEmail =
data.role === "member" && hasFullDomain && emailDomain !== STUDENT_DOMAIN
const alumniRejectsUcsbEmail =
data.role === "alumni" && emailDomain === STUDENT_DOMAIN
const isStudentEmail = STUDENT_DOMAINS.has(emailDomain)
const memberNeedsStudentEmail =
data.role === "member" && hasFullDomain && !isStudentEmail
const alumniRejectsStudentEmail =
data.role === "alumni" && isStudentEmail
const emailRoleMismatch =
currentStep === "credentials" && (memberNeedsUcsbEmail || alumniRejectsUcsbEmail)
currentStep === "credentials" && (memberNeedsStudentEmail || alumniRejectsStudentEmail)

function update(patch: Partial<OnboardingData>) {
setData((prev) => ({ ...prev, ...patch }))
Expand Down Expand Up @@ -399,19 +400,21 @@ export default function OnboardingPage() {
<>
<DialogTitle>Use a personal email</DialogTitle>
<DialogDescription>
UCSB emails expire after graduation. Sign up with a personal email
School emails expire after graduation. Sign up with a personal email
so you keep access after your{" "}
<span className="font-mono text-foreground">@ucsb.edu</span>{" "}
<span className="font-mono text-foreground">@ucsb.edu</span> or{" "}
<span className="font-mono text-foreground">@pipeline.sbcc.edu</span>{" "}
account is deactivated.
</DialogDescription>
</>
) : (
<>
<DialogTitle>UCSB email required</DialogTitle>
<DialogTitle>Student email required</DialogTitle>
<DialogDescription>
Current members must sign up with their{" "}
<span className="font-mono text-foreground">@ucsb.edu</span> email
so we can verify enrollment. You're using{" "}
<span className="font-mono text-foreground">@ucsb.edu</span> or{" "}
<span className="font-mono text-foreground">@pipeline.sbcc.edu</span>{" "}
email so we can verify enrollment. You're using{" "}
<span className="font-mono text-foreground">@{emailDomain}</span>.
</DialogDescription>
</>
Expand All @@ -423,7 +426,7 @@ export default function OnboardingPage() {
innerClassName="bg-popover"
onClick={() => setEmailRoleDialogOpen(false)}
>
{data.role === "alumni" ? "Use a different email" : "Use my UCSB email"}
{data.role === "alumni" ? "Use a different email" : "Use my student email"}
</OutlineButton>
</DialogContent>
</Dialog>
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/onboarding/steps/CredentialsStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function CredentialsStep({ data, update }: StepProps) {
id="email"
type="email"
autoComplete="email"
placeholder="you@ucsb.edu"
placeholder="you@ucsb.edu or you@pipeline.sbcc.edu"
value={data.email}
onChange={(e) => update({ email: e.target.value })}
required
Expand Down
Loading