|
|
@@ -98,6 +98,42 @@ func (app *App) HandleCreateInvite(w http.ResponseWriter, r *http.Request) {
|
|
|
)
|
|
|
}
|
|
|
|
|
|
+// HandleUpdateInviteRole updates the role for a pending invitation
|
|
|
+func (app *App) HandleUpdateInviteRole(w http.ResponseWriter, r *http.Request) {
|
|
|
+ id, err := strconv.ParseUint(chi.URLParam(r, "invite_id"), 0, 64)
|
|
|
+
|
|
|
+ if err != nil || id == 0 {
|
|
|
+ app.handleErrorFormDecoding(err, ErrProjectDecode, w)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ invite, err := app.Repo.Invite.ReadInvite(uint(id))
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ app.handleErrorRead(err, ErrProjectDataRead, w)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ form := &forms.UpdateProjectRoleForm{}
|
|
|
+
|
|
|
+ // decode from JSON to form value
|
|
|
+ if err := json.NewDecoder(r.Body).Decode(form); err != nil {
|
|
|
+ app.handleErrorFormDecoding(err, ErrProjectDecode, w)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ invite.Kind = form.Kind
|
|
|
+
|
|
|
+ invite, err = app.Repo.Invite.UpdateInvite(invite)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ app.handleErrorRead(err, ErrProjectDataRead, w)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ w.WriteHeader(http.StatusOK)
|
|
|
+}
|
|
|
+
|
|
|
// HandleAcceptInvite accepts an invite to a new project: if successful, a new role
|
|
|
// is created for that user in the project
|
|
|
func (app *App) HandleAcceptInvite(w http.ResponseWriter, r *http.Request) {
|