2024-06-22 10:05:41 +00:00
|
|
|
package exts
|
|
|
|
|
|
|
|
import (
|
2024-07-16 06:44:00 +00:00
|
|
|
"git.solsynth.dev/hydrogen/dealer/pkg/proto"
|
2024-06-22 10:05:41 +00:00
|
|
|
"git.solsynth.dev/hydrogen/messaging/pkg/internal/services"
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
func LinkAccountMiddleware(c *fiber.Ctx) error {
|
2024-07-16 06:44:00 +00:00
|
|
|
if val, ok := c.Locals("p_user").(*proto.UserInfo); ok {
|
2024-06-22 10:05:41 +00:00
|
|
|
if account, err := services.LinkAccount(val); err != nil {
|
|
|
|
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
|
|
|
} else {
|
|
|
|
c.Locals("user", account)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return c.Next()
|
|
|
|
}
|