2019-10-07 08:14:47 -06:00
|
|
|
// Copyright (c) Mainflux
|
2019-07-04 17:06:56 +02:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
package http
|
|
|
|
|
|
|
|
import "github.com/mainflux/mainflux/things"
|
|
|
|
|
|
|
|
var _ apiReq = (*identifyReq)(nil)
|
|
|
|
|
|
|
|
type apiReq interface {
|
|
|
|
validate() error
|
|
|
|
}
|
|
|
|
|
|
|
|
type identifyReq struct {
|
|
|
|
Token string `json:"token"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (req identifyReq) validate() error {
|
|
|
|
if req.Token == "" {
|
|
|
|
return things.ErrUnauthorizedAccess
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-10-21 15:24:45 -06:00
|
|
|
type canAccessByKeyReq struct {
|
2019-07-04 17:06:56 +02:00
|
|
|
chanID string
|
|
|
|
Token string `json:"token"`
|
|
|
|
}
|
|
|
|
|
2019-10-21 15:24:45 -06:00
|
|
|
func (req canAccessByKeyReq) validate() error {
|
2019-07-04 17:06:56 +02:00
|
|
|
if req.Token == "" || req.chanID == "" {
|
|
|
|
return things.ErrUnauthorizedAccess
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2019-07-15 18:28:15 +02:00
|
|
|
|
|
|
|
type canAccessByIDReq struct {
|
|
|
|
chanID string
|
|
|
|
ThingID string `json:"thing_id"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (req canAccessByIDReq) validate() error {
|
|
|
|
if req.ThingID == "" || req.chanID == "" {
|
|
|
|
return things.ErrUnauthorizedAccess
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|