Create user

This commit is contained in:
2024-08-23 21:07:13 +02:00
parent 05db85eca1
commit b183e7bf43
6 changed files with 95 additions and 4 deletions

View File

@ -712,3 +712,15 @@ func (app *application) AllUsers(w http.ResponseWriter, r *http.Request) {
}
app.writeJSON(w, http.StatusOK, allUsers)
}
func (app *application) OneUser(w http.ResponseWriter, r *http.Request) {
id := chi.URLParam(r, "id")
userID, _ := strconv.Atoi(id)
user, err := app.DB.GetOneUser(userID)
if err != nil {
app.errorLog.Println(err)
app.badRequest(w, r, err)
return
}
app.writeJSON(w, http.StatusOK, user)
}

View File

@ -38,6 +38,7 @@ func (app *application) routes() http.Handler {
mux.Post("/refund", app.RefundCharge)
mux.Post("/cancel-subscription", app.CancelSubscription)
mux.Post("/all-users", app.AllUsers)
mux.Post("/all-users/{id}", app.OneUser)
})
mux.Post("/api/forgot-password", app.SendPasswordResetEmail)
mux.Post("/api/reset-password", app.ResetPassword)