aboutsummaryrefslogtreecommitdiff
path: root/userapi/inthttp
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2020-09-04 15:16:13 +0100
committerGitHub <noreply@github.com>2020-09-04 15:16:13 +0100
commit5076925c184998414c3691e97fc21b554abf4a55 (patch)
treeb4da4d8a3015166e16eb9a6009f733653f0485bc /userapi/inthttp
parentca8dcf46b746686e213b184c3ae42ba0be17b46b (diff)
Password changes (#1397)
* User API support for password changes * Password changes in client API * Update sytest-whitelist * Remove debug logging * Default logout_devices to true * Fix deleting devices by local part
Diffstat (limited to 'userapi/inthttp')
-rw-r--r--userapi/inthttp/client.go13
-rw-r--r--userapi/inthttp/server.go13
2 files changed, 26 insertions, 0 deletions
diff --git a/userapi/inthttp/client.go b/userapi/inthttp/client.go
index 5f4df0eb..6dcaf756 100644
--- a/userapi/inthttp/client.go
+++ b/userapi/inthttp/client.go
@@ -30,6 +30,7 @@ const (
PerformDeviceCreationPath = "/userapi/performDeviceCreation"
PerformAccountCreationPath = "/userapi/performAccountCreation"
+ PerformPasswordUpdatePath = "/userapi/performPasswordUpdate"
PerformDeviceDeletionPath = "/userapi/performDeviceDeletion"
PerformDeviceUpdatePath = "/userapi/performDeviceUpdate"
@@ -81,6 +82,18 @@ func (h *httpUserInternalAPI) PerformAccountCreation(
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}
+func (h *httpUserInternalAPI) PerformPasswordUpdate(
+ ctx context.Context,
+ request *api.PerformPasswordUpdateRequest,
+ response *api.PerformPasswordUpdateResponse,
+) error {
+ span, ctx := opentracing.StartSpanFromContext(ctx, "PerformPasswordUpdate")
+ defer span.Finish()
+
+ apiURL := h.apiURL + PerformPasswordUpdatePath
+ return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
+}
+
func (h *httpUserInternalAPI) PerformDeviceCreation(
ctx context.Context,
request *api.PerformDeviceCreationRequest,
diff --git a/userapi/inthttp/server.go b/userapi/inthttp/server.go
index 47d68ff2..d2674678 100644
--- a/userapi/inthttp/server.go
+++ b/userapi/inthttp/server.go
@@ -39,6 +39,19 @@ func AddRoutes(internalAPIMux *mux.Router, s api.UserInternalAPI) {
return util.JSONResponse{Code: http.StatusOK, JSON: &response}
}),
)
+ internalAPIMux.Handle(PerformAccountCreationPath,
+ httputil.MakeInternalAPI("performPasswordUpdate", func(req *http.Request) util.JSONResponse {
+ request := api.PerformPasswordUpdateRequest{}
+ response := api.PerformPasswordUpdateResponse{}
+ if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
+ return util.MessageResponse(http.StatusBadRequest, err.Error())
+ }
+ if err := s.PerformPasswordUpdate(req.Context(), &request, &response); err != nil {
+ return util.ErrorResponse(err)
+ }
+ return util.JSONResponse{Code: http.StatusOK, JSON: &response}
+ }),
+ )
internalAPIMux.Handle(PerformDeviceCreationPath,
httputil.MakeInternalAPI("performDeviceCreation", func(req *http.Request) util.JSONResponse {
request := api.PerformDeviceCreationRequest{}