mirror of
https://github.com/pagefaultgames/rogueserver.git
synced 2025-06-28 17:24:08 -04:00
Add password changes
This commit is contained in:
parent
4ce5a0198d
commit
cbcc68f8e4
4 changed files with 59 additions and 0 deletions
|
@ -87,6 +87,28 @@ func handleAccountLogin(w http.ResponseWriter, r *http.Request) {
|
|||
w.Header().Set("Content-Type", "application/json")
|
||||
}
|
||||
|
||||
func handleAccountChangePW(w http.ResponseWriter, r *http.Request) {
|
||||
err := r.ParseForm()
|
||||
if err != nil {
|
||||
httpError(w, r, fmt.Errorf("failed to parse request form: %s", err), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
uuid, err := uuidFromRequest(r)
|
||||
if err != nil {
|
||||
httpError(w, r, err, http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
err = account.ChangePW(uuid, r.Form.Get("password"))
|
||||
if err != nil {
|
||||
httpError(w, r, err, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
||||
func handleAccountLogout(w http.ResponseWriter, r *http.Request) {
|
||||
token, err := tokenFromRequest(r)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue