Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: add notification for license upload (#573)
ecmadaobd80bafeed7f
diff --git a/enterprise/service/license.go b/enterprise/service/license.goindex 9450375830..9995704522 100644--- a/enterprise/service/license.go+++ b/enterprise/service/license.go@@ -33,6 +33,11 @@ func NewLicenseService(l *zap.Logger, dataDir string, mode string) (*LicenseServ// StoreLicense will store license into file.func (s *LicenseService) StoreLicense(tokenString string) error {+ if tokenString != "" {+ if _, err := s.parseLicense(tokenString); err != nil {+ return nil+ }+ }return s.writeLicense(tokenString)}@@ -46,7 +51,11 @@ func (s *LicenseService) LoadLicense() (*enterpriseAPI.License, error) {return nil, common.Errorf(common.NotFound, fmt.Errorf("cannot find license"))}- token, err := jwt.Parse(tokenString, func(token *jwt.Token) (interface{}, error) {+ return s.parseLicense(tokenString)+}++func (s *LicenseService) parseLicense(license string) (*enterpriseAPI.License, error) {+ token, err := jwt.Parse(license, func(token *jwt.Token) (interface{}, error) {if _, ok := token.Method.(*jwt.SigningMethodRSA); !ok {return nil, common.Errorf(common.Invalid, fmt.Errorf("unexpected signing method: %v", token.Header["alg"]))}diff --git a/frontend/src/locales/en.yml b/frontend/src/locales/en.ymlindex 117bf7917d..a416d27103 100644--- a/frontend/src/locales/en.yml+++ b/frontend/src/locales/en.yml@@ -1145,6 +1145,13 @@ subscription:subscribe: Subscribe nowcurrent-plan: Current planbuy: Buy {plan} plan+ update:+ success:+ title: Successfully updated license+ description: Premium features in subscription plan unlocked.+ failure:+ title: Failed to update license+ description: Please check if your license is valid.features:bb-feature-task-schedule-time:title: Set task schedule timediff --git a/frontend/src/locales/zh-CN.yml b/frontend/src/locales/zh-CN.ymlindex 03bb1328e0..f4fd8fdbc8 100644--- a/frontend/src/locales/zh-CN.yml+++ b/frontend/src/locales/zh-CN.yml@@ -1016,6 +1016,13 @@ subscription:subscribe: 开始订阅current-plan: 当前订阅buy: 购买{plan}+ update:+ success:+ title: 证书更新成功+ description: 订阅版高级功能已解锁+ failure:+ title: 证书更新失败+ description: 请检查证书是否有效features:bb-feature-task-schedule-time:title: 设定任务执行时间diff --git a/frontend/src/views/SettingWorkspaceSubscription.vue b/frontend/src/views/SettingWorkspaceSubscription.vueindex 5c5ac90cde..210fd1d988 100644--- a/frontend/src/views/SettingWorkspaceSubscription.vue+++ b/frontend/src/views/SettingWorkspaceSubscription.vue@@ -96,8 +96,22 @@ export default {try {await store.dispatch("subscription/patchSubscription", state.license);+ store.dispatch("notification/pushNotification", {+ module: "bytebase",+ style: "SUCCESS",+ title: t("subscription.update.success.title"),+ description: t("subscription.update.success.description"),+ });+ } catch {+ store.dispatch("notification/pushNotification", {+ module: "bytebase",+ style: "CRITICAL",+ title: t("subscription.update.failure.title"),+ description: t("subscription.update.failure.description"),+ });} finally {state.loading = false;+ state.license = "";}};diff --git a/server/subscription.go b/server/subscription.goindex 8ede27bfb2..49cfc491a9 100644--- a/server/subscription.go+++ b/server/subscription.go@@ -28,7 +28,7 @@ func (s *Server) registerSubscriptionRoutes(g *echo.Group) {}if err := s.LicenseService.StoreLicense(patch.License); err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to create license").SetInternal(err)+ return echo.NewHTTPError(http.StatusInternalServerError, "Failed to store license").SetInternal(err)}s.subscription = s.loadSubscription()@@ -85,5 +85,8 @@ func (s *Server) loadLicense() (*enterpriseAPI.License, error) {}func (s *Server) feature(feature api.FeatureType) bool {+ if expireTime := time.Unix(s.subscription.ExpiresTs, 0); expireTime.Before(time.Now()) {+ return api.FeatureMatrix[feature][api.FREE]+ }return api.FeatureMatrix[feature][s.subscription.Plan]}