@@ -61,18 +61,14 @@ func (a *Application) HandleTeacherLogin(w http.ResponseWriter, r *http.Request)
6161
6262 teacher , err := a .DB .GetTeacherByEmail (r .Context (), emailAddress )
6363 if err != nil {
64- log .Warn ().Err (err ).Msg ("failed to find teacher by email" )
65- a .TeacherLoginRenderer (w , r , map [string ]any {
66- "Email" : emailAddress ,
67- "EmailNotFound" : true ,
68- })
64+ log .Warn ().Err (err ).Msg ("failed to find teacher by email, redirecting without sending email" )
65+ http .SetCookie (w , & http.Cookie {Name : "email" , Value : emailAddress , Path : "/" , HttpOnly : true , SameSite : http .SameSiteLaxMode })
66+ http .Redirect (w , r , "/register/teacher/emaillogin" , http .StatusSeeOther )
6967 return
7068 } else if ! teacher .EmailConfirmed {
71- log .Warn ().Err (err ).Msg ("teacher email not confirmed, not sending login code to avoid amplification attacks" )
72- a .TeacherLoginRenderer (w , r , map [string ]any {
73- "Email" : emailAddress ,
74- "EmailNotConfirmed" : true ,
75- })
69+ log .Warn ().Msg ("teacher email not confirmed, redirecting without sending email" )
70+ http .SetCookie (w , & http.Cookie {Name : "email" , Value : emailAddress , Path : "/" , HttpOnly : true , SameSite : http .SameSiteLaxMode })
71+ http .Redirect (w , r , "/register/teacher/emaillogin" , http .StatusSeeOther )
7672 return
7773 }
7874
0 commit comments