(db database.Store)
| 221 | } |
| 222 | |
| 223 | func 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 | } |
no test coverage detected