mirror of
https://github.com/mainflux/mainflux.git
synced 2025-05-04 22:17:59 +08:00

* MF-1263 - Mv duplicated errors to pkg/errors Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Revert test build flags Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix merge Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix comment Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> Co-authored-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
38 lines
710 B
Go
38 lines
710 B
Go
// Copyright (c) Mainflux
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package keys
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/mainflux/mainflux/auth"
|
|
"github.com/mainflux/mainflux/pkg/errors"
|
|
)
|
|
|
|
type issueKeyReq struct {
|
|
token string
|
|
Type uint32 `json:"type,omitempty"`
|
|
Duration time.Duration `json:"duration,omitempty"`
|
|
}
|
|
|
|
// It is not possible to issue Reset key using HTTP API.
|
|
func (req issueKeyReq) validate() error {
|
|
if req.Type != auth.APIKey || req.token == "" {
|
|
return errors.ErrUnauthorizedAccess
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type keyReq struct {
|
|
token string
|
|
id string
|
|
}
|
|
|
|
func (req keyReq) validate() error {
|
|
if req.token == "" || req.id == "" {
|
|
return errors.ErrMalformedEntity
|
|
}
|
|
return nil
|
|
}
|