1
0
mirror of https://github.com/mainflux/mainflux.git synced 2025-04-29 13:49:28 +08:00
Nick Neisen 6687a738ce MF-785 - Change CanAccess to CanAccessByKey (#894)
* Change CanAccess to CanAccessByKey for things

Signed-off-by: Nick Neisen <nwneisen@gmail.com>

* Change CanAccess in remaining occurances

Signed-off-by: Nick Neisen <nwneisen@gmail.com>

* Regenerate generated files

Signed-off-by: Nick Neisen <nwneisen@gmail.com>

* Generate pb.go files with protoc 3.6.1

Signed-off-by: Nick Neisen <nwneisen@gmail.com>
2019-10-21 23:24:45 +02:00

51 lines
844 B
Go

// Copyright (c) Mainflux
// 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
}
type canAccessByKeyReq struct {
chanID string
Token string `json:"token"`
}
func (req canAccessByKeyReq) validate() error {
if req.Token == "" || req.chanID == "" {
return things.ErrUnauthorizedAccess
}
return nil
}
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
}