Skip to content

Commit 7a70043

Browse files
sumnerevansclaude
andcommitted
security: prevent email enumeration on teacher login
Previously the login form returned distinct errors for "email not found" vs "email not confirmed", allowing enumeration of registered emails. Now all outcomes redirect to the emaillogin page without revealing which case applied. The unreachable EmailNotFound/EmailNotConfirmed template blocks are removed from teacherlogin.html. Update emaillogin.html text to reflect that a login link is only sent if the account exists and is confirmed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 9123caf commit 7a70043

3 files changed

Lines changed: 13 additions & 9 deletions

File tree

internal/teacherlogin.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ func (a *Application) HandleTeacherLogin(w http.ResponseWriter, r *http.Request)
6363
if err != nil {
6464
log.Warn().Err(err).Msg("failed to find teacher by email, redirecting without sending email")
6565
http.SetCookie(w, &http.Cookie{Name: "email", Value: emailAddress, Path: "/", HttpOnly: true, SameSite: http.SameSiteLaxMode})
66-
http.Redirect(w, r, "/register/teacher/confirmemail", http.StatusSeeOther)
66+
http.Redirect(w, r, "/register/teacher/emaillogin", http.StatusSeeOther)
6767
return
6868
} else if !teacher.EmailConfirmed {
6969
log.Warn().Msg("teacher email not confirmed, redirecting without sending email")
7070
http.SetCookie(w, &http.Cookie{Name: "email", Value: emailAddress, Path: "/", HttpOnly: true, SameSite: http.SameSiteLaxMode})
71-
http.Redirect(w, r, "/register/teacher/confirmemail", http.StatusSeeOther)
71+
http.Redirect(w, r, "/register/teacher/emaillogin", http.StatusSeeOther)
7272
return
7373
}
7474

@@ -99,6 +99,6 @@ func (a *Application) HandleTeacherLogin(w http.ResponseWriter, r *http.Request)
9999
} else {
100100
log.Info().Msg("sent email")
101101
http.SetCookie(w, &http.Cookie{Name: "email", Value: emailAddress, Path: "/", HttpOnly: true, SameSite: http.SameSiteLaxMode})
102-
http.Redirect(w, r, "/register/teacher/confirmemail", http.StatusSeeOther)
102+
http.Redirect(w, r, "/register/teacher/emaillogin", http.StatusSeeOther)
103103
}
104104
}

website/templates/confirmemail.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,17 @@ <h1>Confirm Email</h1>
2424
<div class="row">
2525
<div class="col m-4 text-center">
2626
<p>
27-
If <b>{{ .Data.Email }}</b> has a confirmed account, we've sent a login link to that address.
27+
We've sent an email to <b>{{ .Data.Email }}</b>.
2828
</p>
2929
<p style="font-size: 10em; line-height: 0;"><i class="fa fa-envelope-o"></i></p>
3030
<p>
31-
Please check your email and click the link to log in.
31+
Please check your email and click the link to confirm your email address and log in.
3232
</p>
3333
<p>
34-
If you haven't confirmed your email yet, check your inbox for the original confirmation email.
35-
If you need help, <a href="mailto:support@mineshspc.com">contact support</a>.
34+
<b>
35+
You must confirm your email now, or you will have to contact the Mines HSPC team to get
36+
your account activated.
37+
</b>
3638
</p>
3739
</div>
3840
</div>

website/templates/emaillogin.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ <h1>Email Login</h1>
2525
<div class="row">
2626
<div class="col m-4 text-center">
2727
<p>
28-
We've sent an email to <b>{{ .Data.Email }}</b>.
28+
If <b>{{ .Data.Email }}</b> has a confirmed account, we've sent a login link to that address.
2929
</p>
3030
<p style="font-size: 10em; line-height: 0;"><i class="fa fa-envelope-o"></i></p>
3131
<p>
32-
Please check your email and click the link to log in.
32+
Please check your email and click the link to log in. If you haven't confirmed your email
33+
yet, check your inbox for the original confirmation email. Need help?
34+
<a href="mailto:support@mineshspc.com">Contact support</a>.
3335
</p>
3436
</div>
3537
</div>

0 commit comments

Comments
 (0)