route/internal/database/token.go

38 lines
679 B
Go

package database
import "time"
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"`
}
// 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,
}
}