Explorar el Código

make sure downgrades work

abhishek9686 hace 1 año
padre
commit
17cf210f92
Se han modificado 1 ficheros con 9 adiciones y 0 borrados
  1. 9 0
      migrate/migrate.go

+ 9 - 0
migrate/migrate.go

@@ -65,6 +65,7 @@ func assignSuperAdmin() {
 				continue
 			}
 			user.PlatformRoleID = models.SuperAdminRole
+			user.IsSuperAdmin = true
 			err = logic.UpsertUser(*user)
 			if err != nil {
 				slog.Error(
@@ -357,6 +358,14 @@ func syncUsers() {
 	if err == nil {
 		for _, user := range users {
 			user := user
+			if user.PlatformRoleID == models.AdminRole && !user.IsAdmin {
+				user.IsAdmin = true
+				logic.UpsertUser(user)
+			}
+			if user.PlatformRoleID == models.SuperAdminRole && !user.IsSuperAdmin {
+				user.IsSuperAdmin = true
+				logic.UpsertUser(user)
+			}
 			if user.PlatformRoleID.String() != "" {
 				continue
 			}