diff --git a/.idea/workspace.xml b/.idea/workspace.xml index fca4e41..db8f3bf 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -4,20 +4,15 @@ - - + - - + + + - - - - + - - - + @@ -52,34 +47,34 @@ - { + "keyToString": { + "DefaultGoTemplateProperty": "Go File", + "Go Build.Backend.executor": "Run", + "Go 构建.Backend.executor": "Run", + "RunOnceActivity.ShowReadmeOnStart": "true", + "RunOnceActivity.go.formatter.settings.were.checked": "true", + "RunOnceActivity.go.migrated.go.modules.settings": "true", + "RunOnceActivity.go.modules.automatic.dependencies.download": "true", + "RunOnceActivity.go.modules.go.list.on.any.changes.was.set": "true", + "git-widget-placeholder": "refactor/v2", + "go.import.settings.migrated": "true", + "go.sdk.automatically.set": "true", + "last_opened_file_path": "/Users/littlesheep/Documents/Projects/Hydrogen/Passport/web", + "node.js.detected.package.eslint": "true", + "node.js.selected.package.eslint": "(autodetect)", + "nodejs_package_manager_path": "npm", + "run.code.analysis.last.selected.profile": "pProject Default", + "settings.editor.selected.configurable": "preferences.pluginManager", + "ts.external.directory.path": "/Users/littlesheep/Documents/Projects/Hydrogen/Passport/web/node_modules/typescript/lib", + "vue.rearranger.settings.migration": "true" }, - "keyToStringList": { - "DatabaseDriversLRU": [ - "postgresql" + "keyToStringList": { + "DatabaseDriversLRU": [ + "postgresql" ] } -}]]> +} @@ -155,7 +150,6 @@ - @@ -180,7 +174,8 @@ - + + true diff --git a/pkg/internal/database/migrator.go b/pkg/internal/database/migrator.go index febeaf2..61592eb 100644 --- a/pkg/internal/database/migrator.go +++ b/pkg/internal/database/migrator.go @@ -9,7 +9,6 @@ var AutoMaintainRange = []any{ &models.Account{}, &models.AuthFactor{}, &models.AccountProfile{}, - &models.AccountPage{}, &models.AccountContact{}, &models.AccountFriendship{}, &models.Badge{}, diff --git a/pkg/internal/models/accounts.go b/pkg/internal/models/accounts.go index 49bff98..df188a8 100644 --- a/pkg/internal/models/accounts.go +++ b/pkg/internal/models/accounts.go @@ -21,7 +21,6 @@ type Account struct { PermNodes datatypes.JSONMap `json:"perm_nodes"` Profile AccountProfile `json:"profile"` - PersonalPage AccountPage `json:"personal_page"` Badges []Badge `json:"badges"` Contacts []AccountContact `json:"contacts"` RealmIdentities []RealmMember `json:"realm_identities"` diff --git a/pkg/internal/models/profiles.go b/pkg/internal/models/profiles.go index 1800953..1aa5452 100644 --- a/pkg/internal/models/profiles.go +++ b/pkg/internal/models/profiles.go @@ -1,7 +1,6 @@ package models import ( - "gorm.io/datatypes" "time" ) @@ -14,18 +13,3 @@ type AccountProfile struct { Birthday *time.Time `json:"birthday"` AccountID uint `json:"account_id"` } - -type AccountPage struct { - BaseModel - - Content string `json:"content"` - Script string `json:"script"` - Style string `json:"style"` - Links datatypes.JSONSlice[AccountPageLinks] `json:"links"` - AccountID uint `json:"account_id"` -} - -type AccountPageLinks struct { - Label string `json:"label"` - Url string `json:"url"` -} diff --git a/pkg/internal/server/api/index.go b/pkg/internal/server/api/index.go index 9dbbcc1..71a28f5 100644 --- a/pkg/internal/server/api/index.go +++ b/pkg/internal/server/api/index.go @@ -26,9 +26,7 @@ func MapAPIs(app *fiber.App) { me.Put("/banner", setBanner) me.Get("/", getUserinfo) - me.Get("/page", getOwnPersonalPage) me.Put("/", editUserinfo) - me.Put("/page", editPersonalPage) me.Get("/events", getEvents) me.Get("/tickets", getTickets) me.Delete("/tickets/:ticketId", killSession) @@ -49,7 +47,6 @@ func MapAPIs(app *fiber.App) { directory := api.Group("/users/:alias").Name("User Directory") { directory.Get("/", getOtherUserinfo) - directory.Get("/page", getPersonalPage) } api.Post("/users", doRegister) diff --git a/pkg/internal/server/api/page_api.go b/pkg/internal/server/api/page_api.go deleted file mode 100644 index 77c7c43..0000000 --- a/pkg/internal/server/api/page_api.go +++ /dev/null @@ -1,76 +0,0 @@ -package api - -import ( - "git.solsynth.dev/hydrogen/passport/pkg/internal/database" - "git.solsynth.dev/hydrogen/passport/pkg/internal/models" - "git.solsynth.dev/hydrogen/passport/pkg/internal/server/exts" - "github.com/gofiber/fiber/v2" -) - -func getPersonalPage(c *fiber.Ctx) error { - alias := c.Params("alias") - - var account models.Account - if err := database.C. - Where(&models.Account{Name: alias}). - First(&account).Error; err != nil { - return fiber.NewError(fiber.StatusBadRequest, err.Error()) - } - - var page models.AccountPage - if err := database.C. - Where(&models.AccountPage{AccountID: account.ID}). - First(&page).Error; err != nil { - return fiber.NewError(fiber.StatusBadRequest, err.Error()) - } - - return c.JSON(page) -} - -func getOwnPersonalPage(c *fiber.Ctx) error { - if err := exts.EnsureAuthenticated(c); err != nil { - return err - } - user := c.Locals("user").(models.Account) - - var page models.AccountPage - if err := database.C. - Where(&models.AccountPage{AccountID: user.ID}). - FirstOrCreate(&page, &models.AccountPage{AccountID: user.ID}).Error; err != nil { - return fiber.NewError(fiber.StatusBadRequest, err.Error()) - } - - return c.JSON(page) -} - -func editPersonalPage(c *fiber.Ctx) error { - if err := exts.EnsureAuthenticated(c); err != nil { - return err - } - user := c.Locals("user").(models.Account) - - var data struct { - Content string `json:"content"` - Links []models.AccountPageLinks `json:"links"` - } - - if err := exts.BindAndValidate(c, &data); err != nil { - return err - } - - var page models.AccountPage - if err := database.C. - Where(&models.AccountPage{AccountID: user.ID}). - FirstOrInit(&page).Error; err != nil { - return fiber.NewError(fiber.StatusInternalServerError, err.Error()) - } - - page.Content = data.Content - page.Links = data.Links - - if err := database.C.Save(&page).Error; err != nil { - return fiber.NewError(fiber.StatusInternalServerError, err.Error()) - } - - return c.SendStatus(fiber.StatusOK) -} diff --git a/web/src/layouts/user-center.vue b/web/src/layouts/user-center.vue index ddb0690..ca74d7e 100755 --- a/web/src/layouts/user-center.vue +++ b/web/src/layouts/user-center.vue @@ -6,7 +6,6 @@ - diff --git a/web/src/router/index.ts b/web/src/router/index.ts index c31653d..f652ab3 100755 --- a/web/src/router/index.ts +++ b/web/src/router/index.ts @@ -30,12 +30,6 @@ const router = createRouter({ component: () => import("@/views/personalize.vue"), meta: { title: "Your personality" }, }, - { - path: "/me/personal-page", - name: "personal-page", - component: () => import("@/views/personal-page.vue"), - meta: { title: "Your personal page" }, - }, { path: "/me/security", name: "security", diff --git a/web/src/views/personal-page.vue b/web/src/views/personal-page.vue deleted file mode 100755 index 782b1df..0000000 --- a/web/src/views/personal-page.vue +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - - Apply Changes - - - - - - Your personal page has been updated. - - - Something went wrong... {{ error }} - - - -