diff options
Diffstat (limited to 'api4/user.go')
-rw-r--r-- | api4/user.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/api4/user.go b/api4/user.go index 5e97122d7..3d203fbec 100644 --- a/api4/user.go +++ b/api4/user.go @@ -39,6 +39,7 @@ func (api *API) InitUser() { api.BaseRoutes.Users.Handle("/password/reset/send", api.ApiHandler(sendPasswordReset)).Methods("POST") api.BaseRoutes.Users.Handle("/email/verify", api.ApiHandler(verifyUserEmail)).Methods("POST") api.BaseRoutes.Users.Handle("/email/verify/send", api.ApiHandler(sendVerificationEmail)).Methods("POST") + api.BaseRoutes.User.Handle("/terms_of_service", api.ApiSessionRequired(registerServiceTermsAction)).Methods("POST") api.BaseRoutes.User.Handle("/auth", api.ApiSessionRequiredTrustRequester(updateUserAuth)).Methods("PUT") @@ -1544,3 +1545,24 @@ func enableUserAccessToken(c *Context, w http.ResponseWriter, r *http.Request) { c.LogAudit("success - token_id=" + accessToken.Id) ReturnStatusOK(w) } + +func registerServiceTermsAction(c *Context, w http.ResponseWriter, r *http.Request) { + props := model.StringInterfaceFromJson(r.Body) + + userId := c.Session.UserId + serviceTermsId := props["serviceTermsId"].(string) + accepted := props["accepted"].(bool) + + if _, err := c.App.GetServiceTerms(serviceTermsId); err != nil { + c.Err = err + return + } + + if err := c.App.RecordUserServiceTermsAction(userId, serviceTermsId, accepted); err != nil { + c.Err = err + return + } + + c.LogAudit("ServiceTermsId=" + serviceTermsId + ", accepted=" + strconv.FormatBool(accepted)) + ReturnStatusOK(w) +} |