mirror of
https://github.com/makayabou/asg-server.git
synced 2026-05-02 17:43:36 +02:00
[api/mobile] fix registration auth in private mode
This commit is contained in:
parent
83e9b66ca0
commit
9880f79248
@ -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}}"
|
||||
],
|
||||
|
||||
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user