🚑 Fix getting user panic again...

This commit is contained in:
LittleSheep 2024-06-27 00:58:32 +08:00
parent 3f0d3fc69e
commit b2b8aa467b
2 changed files with 6 additions and 6 deletions

6
.idea/workspace.xml generated
View File

@ -4,7 +4,7 @@
<option name="autoReloadType" value="ALL" /> <option name="autoReloadType" value="ALL" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":ambulance: Fix nil pointer panic"> <list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":bug: Not supposed to appear to status at the same time">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/statuses_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/statuses_api.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/pkg/internal/server/api/statuses_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/statuses_api.go" afterDir="false" />
</list> </list>
@ -152,7 +152,6 @@
</option> </option>
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<MESSAGE value=":recycle: Update the sign in web page to the latest API" />
<MESSAGE value=":wastebasket: Remove the personal page" /> <MESSAGE value=":wastebasket: Remove the personal page" />
<MESSAGE value=":recycle: OAuth authenticate" /> <MESSAGE value=":recycle: OAuth authenticate" />
<MESSAGE value=":sparkles: Recommend app component" /> <MESSAGE value=":sparkles: Recommend app component" />
@ -177,7 +176,8 @@
<MESSAGE value=":bug: Fix ws security blocked" /> <MESSAGE value=":bug: Fix ws security blocked" />
<MESSAGE value=":bug: Invisible status is visible to others" /> <MESSAGE value=":bug: Invisible status is visible to others" />
<MESSAGE value=":ambulance: Fix nil pointer panic" /> <MESSAGE value=":ambulance: Fix nil pointer panic" />
<option name="LAST_COMMIT_MESSAGE" value=":ambulance: Fix nil pointer panic" /> <MESSAGE value=":bug: Not supposed to appear to status at the same time" />
<option name="LAST_COMMIT_MESSAGE" value=":bug: Not supposed to appear to status at the same time" />
</component> </component>
<component name="VgoProject"> <component name="VgoProject">
<settings-migrated>true</settings-migrated> <settings-migrated>true</settings-migrated>

View File

@ -55,10 +55,10 @@ func getMyselfStatus(c *fiber.Ctx) error {
} }
func setStatus(c *fiber.Ctx) error { func setStatus(c *fiber.Ctx) error {
user := c.Locals("user").(models.Account)
if err := exts.EnsureAuthenticated(c); err != nil { if err := exts.EnsureAuthenticated(c); err != nil {
return err return err
} }
user := c.Locals("user").(models.Account)
var req struct { var req struct {
Type string `json:"type" validate:"required"` Type string `json:"type" validate:"required"`
@ -97,10 +97,10 @@ func setStatus(c *fiber.Ctx) error {
} }
func editStatus(c *fiber.Ctx) error { func editStatus(c *fiber.Ctx) error {
user := c.Locals("user").(models.Account)
if err := exts.EnsureAuthenticated(c); err != nil { if err := exts.EnsureAuthenticated(c); err != nil {
return err return err
} }
user := c.Locals("user").(models.Account)
var req struct { var req struct {
Type string `json:"type" validate:"required"` Type string `json:"type" validate:"required"`
@ -135,10 +135,10 @@ func editStatus(c *fiber.Ctx) error {
} }
func clearStatus(c *fiber.Ctx) error { func clearStatus(c *fiber.Ctx) error {
user := c.Locals("user").(models.Account)
if err := exts.EnsureAuthenticated(c); err != nil { if err := exts.EnsureAuthenticated(c); err != nil {
return err return err
} }
user := c.Locals("user").(models.Account)
if err := services.ClearStatus(user); err != nil { if err := services.ClearStatus(user); err != nil {
return fiber.NewError(fiber.StatusInternalServerError, err.Error()) return fiber.NewError(fiber.StatusInternalServerError, err.Error())