diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 7536419..a71933a 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,24 +4,10 @@
-
-
+
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
@@ -56,32 +42,32 @@
- {
+ "keyToString": {
+ "DefaultGoTemplateProperty": "Go File",
+ "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": "master",
+ "go.import.settings.migrated": "true",
+ "go.sdk.automatically.set": "true",
+ "last_opened_file_path": "/Users/littlesheep/Documents/Projects/Hydrogen/Passport/pkg/server/ui",
+ "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.lookFeel",
+ "vue.rearranger.settings.migration": "true"
},
- "keyToStringList": {
- "DatabaseDriversLRU": [
- "postgresql"
+ "keyToStringList": {
+ "DatabaseDriversLRU": [
+ "postgresql"
]
}
-}]]>
+}
@@ -154,7 +140,6 @@
-
@@ -179,7 +164,8 @@
-
+
+
true
diff --git a/pkg/cmd/main.go b/pkg/cmd/main.go
index f092b93..4dd3f45 100644
--- a/pkg/cmd/main.go
+++ b/pkg/cmd/main.go
@@ -53,6 +53,11 @@ func main() {
log.Info().Msg("Successfully setup firebase communication.")
}
+ // Connect other services
+ if err := grpc.ConnectPaperclip(); err != nil {
+ log.Fatal().Err(err).Msg("An error occurred when connecting to paperclip...")
+ }
+
// Server
server.NewServer()
go server.Listen()
diff --git a/pkg/server/avatar_api.go b/pkg/server/avatar_api.go
index 6cb6c53..2582e93 100644
--- a/pkg/server/avatar_api.go
+++ b/pkg/server/avatar_api.go
@@ -7,6 +7,7 @@ import (
"git.solsynth.dev/hydrogen/passport/pkg/database"
"git.solsynth.dev/hydrogen/passport/pkg/grpc"
"git.solsynth.dev/hydrogen/passport/pkg/models"
+ "git.solsynth.dev/hydrogen/passport/pkg/utils"
"github.com/gofiber/fiber/v2"
"github.com/samber/lo"
)
@@ -15,7 +16,11 @@ func setAvatar(c *fiber.Ctx) error {
user := c.Locals("principal").(models.Account)
var data struct {
- AttachmentID string `json:"attachment"`
+ AttachmentID string `json:"attachment" validate:"required"`
+ }
+
+ if err := utils.BindAndValidate(c, &data); err != nil {
+ return err
}
if _, err := grpc.Attachments.CheckAttachmentExists(context.Background(), &pcpb.AttachmentLookupRequest{
@@ -36,8 +41,13 @@ func setAvatar(c *fiber.Ctx) error {
func setBanner(c *fiber.Ctx) error {
user := c.Locals("principal").(models.Account)
+
var data struct {
- AttachmentID string `json:"attachment"`
+ AttachmentID string `json:"attachment" validate:"required"`
+ }
+
+ if err := utils.BindAndValidate(c, &data); err != nil {
+ return err
}
if _, err := grpc.Attachments.CheckAttachmentExists(context.Background(), &pcpb.AttachmentLookupRequest{