Skip to content

Commit d5337ba

Browse files
committed
[handlers] unify user store in locals
1 parent 3513684 commit d5337ba

File tree

1 file changed

+6
-2
lines changed
  • internal/sms-gateway/handlers/middlewares/userauth

1 file changed

+6
-2
lines changed

internal/sms-gateway/handlers/middlewares/userauth/userauth.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func NewBasic(authSvc *auth.Service) fiber.Handler {
5050
return fiber.ErrUnauthorized
5151
}
5252

53-
c.Locals(localsUser, user)
53+
SetUser(c, user)
5454

5555
return c.Next()
5656
}
@@ -77,12 +77,16 @@ func NewCode(authSvc *auth.Service) fiber.Handler {
7777
return fiber.ErrUnauthorized
7878
}
7979

80-
c.Locals(localsUser, user)
80+
SetUser(c, user)
8181

8282
return c.Next()
8383
}
8484
}
8585

86+
func SetUser(c *fiber.Ctx, user *models.User) {
87+
c.Locals(localsUser, user)
88+
}
89+
8690
// HasUser checks if a user is present in the Locals of the given context.
8791
// It returns true if the Locals contain a user under the key LocalsUser,
8892
// otherwise returns false.

0 commit comments

Comments
 (0)