feat: register via json

also lots of refactoring (sorry)
This commit is contained in:
Teajey 2024-11-20 17:42:20 +09:00
parent 782ffbbe6d
commit d2fb0fa707
Signed by: Teajey
GPG Key ID: 970E790FE834A713
1 changed files with 2 additions and 2 deletions

View File

@ -50,14 +50,14 @@ func (ctx *Context) RegisterPost(w http.ResponseWriter, r *http.Request) {
ctx.RedirectWithFlash(w, r, "/", "successful_registration", true) ctx.RedirectWithFlash(w, r, "/", "successful_registration", true)
} }
type jsonParams struct { type registerJsonParams struct {
Username string Username string
NewPassword string NewPassword string
ConfirmPassword string ConfirmPassword string
} }
func (ctx *Context) RegisterPostJson(w http.ResponseWriter, r *http.Request) { func (ctx *Context) RegisterPostJson(w http.ResponseWriter, r *http.Request) {
var params jsonParams var params registerJsonParams
err := decodeJsonParams(r, &params) err := decodeJsonParams(r, &params)
if err != nil { if err != nil {
writeGeneralError(w, "Failed to decode json params: "+err.Error(), http.StatusBadRequest) writeGeneralError(w, "Failed to decode json params: "+err.Error(), http.StatusBadRequest)