MCPcopy Index your code
hub / github.com/coder/coder / RevokeApp

Function RevokeApp

coderd/oauth2provider/revoke.go:223–254  ·  view source on GitHub ↗
(db database.Store)

Source from the content-addressed store, hash-verified

221}
222
223func RevokeApp(db database.Store) http.HandlerFunc {
224 return func(rw http.ResponseWriter, r *http.Request) {
225 ctx := r.Context()
226 apiKey := httpmw.APIKey(r)
227 app := httpmw.OAuth2ProviderApp(r)
228
229 err := db.InTx(func(tx database.Store) error {
230 err := tx.DeleteOAuth2ProviderAppCodesByAppAndUserID(ctx, database.DeleteOAuth2ProviderAppCodesByAppAndUserIDParams{
231 AppID: app.ID,
232 UserID: apiKey.UserID,
233 })
234 if err != nil && !errors.Is(err, sql.ErrNoRows) {
235 return err
236 }
237
238 err = tx.DeleteOAuth2ProviderAppTokensByAppAndUserID(ctx, database.DeleteOAuth2ProviderAppTokensByAppAndUserIDParams{
239 AppID: app.ID,
240 UserID: apiKey.UserID,
241 })
242 if err != nil && !errors.Is(err, sql.ErrNoRows) {
243 return err
244 }
245
246 return nil
247 }, nil)
248 if err != nil {
249 httpapi.InternalServerError(rw, err)
250 return
251 }
252 rw.WriteHeader(http.StatusNoContent)
253 }
254}

Callers 1

Calls 9

APIKeyFunction · 0.92
OAuth2ProviderAppFunction · 0.92
InternalServerErrorFunction · 0.92
ContextMethod · 0.65
InTxMethod · 0.65
IsMethod · 0.45
WriteHeaderMethod · 0.45

Tested by

no test coverage detected