aboutsummaryrefslogtreecommitdiff
path: root/userapi/inthttp
diff options
context:
space:
mode:
authorLoïck Bonniot <git@lesterpig.com>2020-10-02 18:18:20 +0200
committerGitHub <noreply@github.com>2020-10-02 17:18:20 +0100
commit4e8c484618f5bfd5b7349cc2afd102cd5feb3861 (patch)
tree915618d3127f7ead8c5cce5a5814ae861841498a /userapi/inthttp
parent279044cd90722ba98b018b0aa277285113454822 (diff)
Implement account deactivation (#1455)
* Implement account deactivation See #610 Signed-off-by: Loïck Bonniot <git@lesterpig.com> * Rename 'is_active' to 'is_deactivated' Signed-off-by: Loïck Bonniot <git@lesterpig.com> Co-authored-by: Kegsay <kegan@matrix.org>
Diffstat (limited to 'userapi/inthttp')
-rw-r--r--userapi/inthttp/client.go19
-rw-r--r--userapi/inthttp/server.go13
2 files changed, 27 insertions, 5 deletions
diff --git a/userapi/inthttp/client.go b/userapi/inthttp/client.go
index 6dcaf756..4d9dcc41 100644
--- a/userapi/inthttp/client.go
+++ b/userapi/inthttp/client.go
@@ -28,11 +28,12 @@ import (
const (
InputAccountDataPath = "/userapi/inputAccountData"
- PerformDeviceCreationPath = "/userapi/performDeviceCreation"
- PerformAccountCreationPath = "/userapi/performAccountCreation"
- PerformPasswordUpdatePath = "/userapi/performPasswordUpdate"
- PerformDeviceDeletionPath = "/userapi/performDeviceDeletion"
- PerformDeviceUpdatePath = "/userapi/performDeviceUpdate"
+ PerformDeviceCreationPath = "/userapi/performDeviceCreation"
+ PerformAccountCreationPath = "/userapi/performAccountCreation"
+ PerformPasswordUpdatePath = "/userapi/performPasswordUpdate"
+ PerformDeviceDeletionPath = "/userapi/performDeviceDeletion"
+ PerformDeviceUpdatePath = "/userapi/performDeviceUpdate"
+ PerformAccountDeactivationPath = "/userapi/performAccountDeactivation"
QueryProfilePath = "/userapi/queryProfile"
QueryAccessTokenPath = "/userapi/queryAccessToken"
@@ -126,6 +127,14 @@ func (h *httpUserInternalAPI) PerformDeviceUpdate(ctx context.Context, req *api.
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, req, res)
}
+func (h *httpUserInternalAPI) PerformAccountDeactivation(ctx context.Context, req *api.PerformAccountDeactivationRequest, res *api.PerformAccountDeactivationResponse) error {
+ span, ctx := opentracing.StartSpanFromContext(ctx, "PerformAccountDeactivation")
+ defer span.Finish()
+
+ apiURL := h.apiURL + PerformAccountDeactivationPath
+ return httputil.PostJSON(ctx, span, h.httpClient, apiURL, req, res)
+}
+
func (h *httpUserInternalAPI) QueryProfile(
ctx context.Context,
request *api.QueryProfileRequest,
diff --git a/userapi/inthttp/server.go b/userapi/inthttp/server.go
index d2674678..e24aad3a 100644
--- a/userapi/inthttp/server.go
+++ b/userapi/inthttp/server.go
@@ -91,6 +91,19 @@ func AddRoutes(internalAPIMux *mux.Router, s api.UserInternalAPI) {
return util.JSONResponse{Code: http.StatusOK, JSON: &response}
}),
)
+ internalAPIMux.Handle(PerformAccountDeactivationPath,
+ httputil.MakeInternalAPI("performAccountDeactivation", func(req *http.Request) util.JSONResponse {
+ request := api.PerformAccountDeactivationRequest{}
+ response := api.PerformAccountDeactivationResponse{}
+ if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
+ return util.MessageResponse(http.StatusBadRequest, err.Error())
+ }
+ if err := s.PerformAccountDeactivation(req.Context(), &request, &response); err != nil {
+ return util.ErrorResponse(err)
+ }
+ return util.JSONResponse{Code: http.StatusOK, JSON: &response}
+ }),
+ )
internalAPIMux.Handle(QueryProfilePath,
httputil.MakeInternalAPI("queryProfile", func(req *http.Request) util.JSONResponse {
request := api.QueryProfileRequest{}