chore: remove deprecated templ files and update auth routes
BREAKING: migrates to templ from html templates in login, register and welcome pages
This commit is contained in:
@@ -16,6 +16,10 @@ func RegisterRoutes(mux *http.ServeMux) {
|
||||
mux.HandleFunc("GET /register/step/{step}", handleRegisterStep)
|
||||
mux.HandleFunc("GET /register/capabilities", handleRegisterCapabilities)
|
||||
mux.HandleFunc("POST /register/verify-code", handleRegisterVerifyCode)
|
||||
|
||||
mux.HandleFunc("GET /login", handleLogin)
|
||||
mux.HandleFunc("GET /login/step/{step}", handleLoginStep)
|
||||
mux.HandleFunc("GET /login/qr-status", handleLoginQRStatus)
|
||||
}
|
||||
|
||||
// handleWelcome renders the full welcome page at step 1
|
||||
@@ -85,3 +89,36 @@ func handleRegisterVerifyCode(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
views.RegisterPage(state).Render(r.Context(), w)
|
||||
}
|
||||
|
||||
func handleLogin(w http.ResponseWriter, r *http.Request) {
|
||||
state := views.LoginState{Step: "1"}
|
||||
views.LoginPage(state).Render(r.Context(), w)
|
||||
}
|
||||
|
||||
func handleLoginStep(w http.ResponseWriter, r *http.Request) {
|
||||
step := r.PathValue("step")
|
||||
if step == "" {
|
||||
step = "1"
|
||||
}
|
||||
|
||||
state := views.LoginState{Step: step}
|
||||
|
||||
if r.Header.Get("HX-Request") == "true" {
|
||||
views.LoginStepWithOOB(state).Render(r.Context(), w)
|
||||
return
|
||||
}
|
||||
|
||||
views.LoginPage(state).Render(r.Context(), w)
|
||||
}
|
||||
|
||||
var qrPollCount = 0
|
||||
|
||||
func handleLoginQRStatus(w http.ResponseWriter, r *http.Request) {
|
||||
qrPollCount++
|
||||
if qrPollCount >= 3 {
|
||||
qrPollCount = 0
|
||||
views.QRStatusSuccess().Render(r.Context(), w)
|
||||
return
|
||||
}
|
||||
views.QRStatusWaiting().Render(r.Context(), w)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user