lot of new functionalities
This commit is contained in:
37
servers/web/auth/onboarding.go
Normal file
37
servers/web/auth/onboarding.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
func (h *Handler) Onboarding(w http.ResponseWriter, r *http.Request) {
|
||||
r.ParseForm()
|
||||
|
||||
key := r.FormValue("key")
|
||||
onboarding, err := h.applicationHandler.GetOnboardingData(key)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Failed to get onboarding data")
|
||||
h.renderer.AuthOnboardingKO(w, r, key)
|
||||
return
|
||||
}
|
||||
|
||||
if r.Method == "POST" {
|
||||
firstName := r.FormValue("first_name")
|
||||
lastName := r.FormValue("last_name")
|
||||
password := r.FormValue("password")
|
||||
|
||||
_, err := h.applicationHandler.CompleteOnboarding(key, password, firstName, lastName)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Failed to complete onboarding")
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
http.Redirect(w, r, "/app/", http.StatusFound)
|
||||
return
|
||||
}
|
||||
|
||||
h.renderer.AuthOnboarding(w, r, key, onboarding)
|
||||
}
|
||||
Reference in New Issue
Block a user