route/internal/database/token.go

38 lines
679 B
Go
Raw Normal View History

package database
import "time"
2017-04-29 02:47:24 +00:00
import (
proto "git.xeserv.us/xena/route/proto"
"github.com/Xe/ln"
)
// Token is a single authorization token.
type Token struct {
ID string `storm:"id"`
Body string `storm:"unique"`
Owner string `storm:"index"`
Scopes []string
CreatedAt time.Time `json:"created_at"`
Active bool `json:"active"`
}
2017-04-29 02:47:24 +00:00
// F https://godoc.org/github.com/Xe/ln#F
func (t Token) F() ln.F {
return ln.F{
"token-id": t.ID,
"token-owner": t.Owner,
"token-active": t.Active,
}
}
// AsProto ...
func (t Token) AsProto() *proto.Token {
return &proto.Token{
Id: t.ID,
Body: t.Body,
Scopes: t.Scopes,
Active: t.Active,
}
}