feat: remove register json post endpoint
This commit is contained in:
parent
994f4ee64a
commit
5a4097f4fe
|
|
@ -51,7 +51,6 @@ func main() {
|
|||
r.Html.Private.Handle("GET /group/{groupReference}", route.ExpectUser(route.GroupPage))
|
||||
r.Html.Private.HandleFunc("POST /logout", route.LogoutPost)
|
||||
|
||||
r.Json.Public.HandleFunc("POST /register", route.RegisterPostJson)
|
||||
r.Json.Public.HandleFunc("GET /", routing.NotFoundJson)
|
||||
|
||||
r.Json.Private.Handle("GET /users", route.ExpectUser(route.UsersJson))
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
)
|
||||
|
||||
func NotFoundJson(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Add("Content-Type", "application/json; charset=utf-8")
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
_, _ = w.Write([]byte(`{"GeneralError":"Not Found"}`))
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,27 +45,9 @@ func (ctx *Context) RegisterPost(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
if props != nil {
|
||||
ctx.RedirectWithFlash(w, r, "/register", "register_props", &props)
|
||||
_ = json.NewEncoder(w).Encode(props)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.RedirectWithFlash(w, r, "/", "successful_registration", true)
|
||||
}
|
||||
|
||||
type registerJsonParams struct {
|
||||
Username string
|
||||
NewPassword string
|
||||
ConfirmPassword string
|
||||
}
|
||||
|
||||
func (ctx *Context) RegisterPostJson(w http.ResponseWriter, r *http.Request) {
|
||||
var params registerJsonParams
|
||||
err := decodeJsonParams(r, ¶ms)
|
||||
if err != nil {
|
||||
writeGeneralError(w, "Failed to decode json params: "+err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
props := api.Register(params.Username, params.NewPassword, params.ConfirmPassword)
|
||||
|
||||
_ = json.NewEncoder(w).Encode(props)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue