From c7513aa25014eed8b874752630fde507a26c7b0e Mon Sep 17 00:00:00 2001 From: Roland <33993199+rolznz@users.noreply.github.com> Date: Fri, 26 Jul 2024 23:08:32 +0700 Subject: [PATCH] fix: remove app permissions with invalid scopes (#353) --- .../202407262257_remove_invalid_scopes.go | 28 +++++++++++++++++++ db/migrations/migrate.go | 1 + frontend/src/types.ts | 1 - 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 db/migrations/202407262257_remove_invalid_scopes.go diff --git a/db/migrations/202407262257_remove_invalid_scopes.go b/db/migrations/202407262257_remove_invalid_scopes.go new file mode 100644 index 00000000..903c396c --- /dev/null +++ b/db/migrations/202407262257_remove_invalid_scopes.go @@ -0,0 +1,28 @@ +package migrations + +import ( + _ "embed" + + "github.com/go-gormigrate/gormigrate/v2" + "gorm.io/gorm" +) + +// This migration removes old app permissions for request methods (now we use scopes) +var _202407262257_remove_invalid_scopes = &gormigrate.Migration{ + ID: "202407262257_remove_invalid_scopes", + Migrate: func(tx *gorm.DB) error { + + if err := tx.Exec(` +delete from app_permissions where scope = "pay_keysend"; +delete from app_permissions where scope = "multi_pay_keysend"; +delete from app_permissions where scope = "multi_pay_invoice"; +`).Error; err != nil { + return err + } + + return nil + }, + Rollback: func(tx *gorm.DB) error { + return nil + }, +} diff --git a/db/migrations/migrate.go b/db/migrations/migrate.go index 2af0ca2c..104ddf24 100644 --- a/db/migrations/migrate.go +++ b/db/migrations/migrate.go @@ -18,6 +18,7 @@ func Migrate(gormDB *gorm.DB) error { _202407012100_transactions, _202407151352_autoincrement, _202407201604_transactions_indexes, + _202407262257_remove_invalid_scopes, }) return m.Migrate() diff --git a/frontend/src/types.ts b/frontend/src/types.ts index d2d4bc8c..b26c4d51 100644 --- a/frontend/src/types.ts +++ b/frontend/src/types.ts @@ -110,7 +110,6 @@ export interface ErrorResponse { export interface App { id: number; - userId: number; name: string; description: string; nostrPubkey: string;