Update user.go
This commit is contained in:
parent
1c1b55f22c
commit
71718438d6
@ -76,19 +76,12 @@ func (c *Controller) GetCurrentAccount(ctx *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
func (c *Controller) ConnectAccount(ctx *fiber.Ctx) error {
|
||||
authHeader := ctx.Get("Authorization")
|
||||
if authHeader == "" {
|
||||
ctx.Status(fiber.StatusUnauthorized).SendString("no JWT found")
|
||||
return nil
|
||||
accountID, ok := middleware.GetAccountId(ctx)
|
||||
if !ok {
|
||||
return ctx.Status(fiber.StatusUnauthorized).SendString("account id is required")
|
||||
}
|
||||
|
||||
tokenString := strings.TrimPrefix(authHeader, "Bearer ")
|
||||
if tokenString == authHeader {
|
||||
ctx.Status(fiber.StatusUnauthorized).SendString("invalid JWT Header: missing Bearer")
|
||||
return nil
|
||||
}
|
||||
|
||||
response, err := c.service.ConnectAccount(ctx.Context(), tokenString)
|
||||
response, err := c.service.ConnectAccount(ctx.Context(), accountID)
|
||||
if err != nil {
|
||||
c.logger.Error("error connect account", zap.Error(err))
|
||||
return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
|
||||
|
Loading…
Reference in New Issue
Block a user