1
0
mirror of https://github.com/Luzifer/cloudkeys-go.git synced 2024-09-19 15:42:58 +00:00

Minor API fixes

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2018-11-04 14:30:02 +01:00
parent b4793cbab5
commit 4379055434
Signed by: luzifer
GPG Key ID: DC2729FDD34BE99E

View File

@ -34,7 +34,7 @@ func apiChangeLoginPassword(ctx context.Context, res http.ResponseWriter, r *htt
username = mux.Vars(r)["user"]
)
if err := json.NewDecoder(r.Body).Decode(input); err != nil {
if err := json.NewDecoder(r.Body).Decode(&input); err != nil {
return nil, http.StatusBadRequest, wrapAPIError(err, "Unable to decode login data")
}
@ -132,7 +132,7 @@ func apiLogin(ctx context.Context, res http.ResponseWriter, r *http.Request, ses
output = map[string]interface{}{"success": true}
)
if err := json.NewDecoder(r.Body).Decode(input); err != nil {
if err := json.NewDecoder(r.Body).Decode(&input); err != nil {
return nil, http.StatusBadRequest, wrapAPIError(err, "Unable to decode login data")
}
@ -212,7 +212,7 @@ func apiRegister(ctx context.Context, res http.ResponseWriter, r *http.Request,
output = map[string]interface{}{"success": true}
)
if err := json.NewDecoder(r.Body).Decode(input); err != nil {
if err := json.NewDecoder(r.Body).Decode(&input); err != nil {
return nil, http.StatusBadRequest, wrapAPIError(err, "Unable to decode request")
}
@ -240,6 +240,9 @@ func apiRegister(ctx context.Context, res http.ResponseWriter, r *http.Request,
return nil, http.StatusInternalServerError, wrapAPIError(err, "Could not write data file")
}
// Log-in the newly created user
sess.Users[input.Username] = userStateLoggedin
return output, http.StatusOK, nil
}
@ -259,7 +262,7 @@ func apiSetUserData(ctx context.Context, res http.ResponseWriter, r *http.Reques
username = mux.Vars(r)["user"]
)
if err := json.NewDecoder(r.Body).Decode(input); err != nil {
if err := json.NewDecoder(r.Body).Decode(&input); err != nil {
return nil, http.StatusBadRequest, wrapAPIError(err, "Unable to decode request")
}
@ -315,7 +318,7 @@ func apiValidateMFA(ctx context.Context, res http.ResponseWriter, r *http.Reques
user = mux.Vars(r)["user"]
)
if err := json.NewDecoder(r.Body).Decode(input); err != nil {
if err := json.NewDecoder(r.Body).Decode(&input); err != nil {
return nil, http.StatusBadRequest, wrapAPIError(err, "Unable to decode login data")
}