From b2b8aa467bc33a7909a7c9cbed4c480b4b5a8f13 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Thu, 27 Jun 2024 00:58:32 +0800 Subject: [PATCH] :ambulance: Fix getting user panic again... --- .idea/workspace.xml | 6 +++--- pkg/internal/server/api/statuses_api.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 9e9f776..2c61561 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -4,7 +4,7 @@ - @@ -177,7 +176,8 @@ - true diff --git a/pkg/internal/server/api/statuses_api.go b/pkg/internal/server/api/statuses_api.go index 17eb42c..6c097cc 100644 --- a/pkg/internal/server/api/statuses_api.go +++ b/pkg/internal/server/api/statuses_api.go @@ -55,10 +55,10 @@ func getMyselfStatus(c *fiber.Ctx) error { } func setStatus(c *fiber.Ctx) error { - user := c.Locals("user").(models.Account) if err := exts.EnsureAuthenticated(c); err != nil { return err } + user := c.Locals("user").(models.Account) var req struct { Type string `json:"type" validate:"required"` @@ -97,10 +97,10 @@ func setStatus(c *fiber.Ctx) error { } func editStatus(c *fiber.Ctx) error { - user := c.Locals("user").(models.Account) if err := exts.EnsureAuthenticated(c); err != nil { return err } + user := c.Locals("user").(models.Account) var req struct { Type string `json:"type" validate:"required"` @@ -135,10 +135,10 @@ func editStatus(c *fiber.Ctx) error { } func clearStatus(c *fiber.Ctx) error { - user := c.Locals("user").(models.Account) if err := exts.EnsureAuthenticated(c); err != nil { return err } + user := c.Locals("user").(models.Account) if err := services.ClearStatus(user); err != nil { return fiber.NewError(fiber.StatusInternalServerError, err.Error())