[api/mobile] fix registration auth in private mode

This commit is contained in:
Aleksandr Soloshenko 2024-03-13 00:07:37 +07:00
parent 83e9b66ca0
commit 9880f79248
2 changed files with 7 additions and 10 deletions

View File

@ -5,7 +5,7 @@
###
POST {{baseUrl}}/api/mobile/v1/device HTTP/1.1
Authorization: 123456789
Authorization: Bearer 123456789
Content-Type: application/json
{
@ -20,7 +20,7 @@ Authorization: Basic {{credentials}}
{
"message": "{{$localDatetime iso8601}}",
"validUntil": "2024-02-10T12:00:00+07:00",
"ttl": 600,
"phoneNumbers": [
"{{phone}}"
],

View File

@ -170,14 +170,11 @@ func (h *mobileHandler) authorize(handler func(models.Device, *fiber.Ctx) error)
func (h *mobileHandler) Register(router fiber.Router) {
router = router.Group("/mobile/v1")
router.Post("/device", limiter.New(), func(c *fiber.Ctx) error {
token := c.Get(fiber.HeaderAuthorization)
if h.authSvc.AuthorizeRegistration(token) != nil {
return fiber.ErrUnauthorized
}
return c.Next()
}, h.postDevice)
router.Post("/device", limiter.New(), apikey.New(apikey.Config{
Authorizer: func(token string) bool {
return h.authSvc.AuthorizeRegistration(token) == nil
},
}), h.postDevice)
router.Use(apikey.New(apikey.Config{
Authorizer: func(token string) bool {