homebox/backend/internal/repo/token_interface.go

21 lines
743 B
Go
Raw Normal View History

2022-08-30 02:30:36 +00:00
package repo
import (
"context"
2022-08-30 02:40:54 +00:00
"github.com/hay-kot/content/backend/internal/types"
2022-08-30 02:30:36 +00:00
)
type TokenRepository interface {
// GetUserFromToken get's a user from a token
GetUserFromToken(ctx context.Context, token []byte) (types.UserOut, error)
// Creates a token for a user
CreateToken(ctx context.Context, createToken types.UserAuthTokenCreate) (types.UserAuthToken, error)
// DeleteToken remove a single token from the database - equivalent to revoke or logout
DeleteToken(ctx context.Context, token []byte) error
// PurgeExpiredTokens removes all expired tokens from the database
PurgeExpiredTokens(ctx context.Context) (int, error)
// DeleteAll removes all tokens from the database
DeleteAll(ctx context.Context) (int, error)
}