store

package
v0.0.0-...-da48aa0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSONToToken

func JSONToToken(s []byte) *oauth2.Token

JSONToToken turns stored JSON into a token.

func TokenToJSON

func TokenToJSON(t *oauth2.Token) []byte

TokenToJSON serializes an oauth2 token.

Types

type PostgresqlStore

type PostgresqlStore struct {
	// contains filtered or unexported fields
}

PostgresqlStore is a storage engine that writes to postgres

func NewPostgresqlStore

func NewPostgresqlStore(connStr string) (*PostgresqlStore, error)

NewPostgresqlStore creates new store

func (*PostgresqlStore) GetUser

func (s *PostgresqlStore) GetUser(ctx context.Context, id string) (*User, error)

GetUser will load a user from postgres

func (*PostgresqlStore) Ping

func (s *PostgresqlStore) Ping(ctx context.Context) error

Ping will check if the connection works right

func (*PostgresqlStore) WriteUser

func (s *PostgresqlStore) WriteUser(ctx context.Context, user *User) error

WriteUser will write a user object to postgres

type Store

type Store interface {
	WriteUser(ctx context.Context, user *User) error
	GetUser(ctx context.Context, id string) (*User, error)
	Ping(ctx context.Context) error
}

Store is the interface for All the store types

type User

type User struct {
	ID       string
	Username string
	Token    *oauth2.Token
	Updated  time.Time
	// contains filtered or unexported fields
}

User object

func NewUser

func NewUser(ctx context.Context, username string, token *oauth2.Token, storage Store) (*User, error)

NewUser creates a new user object

func (*User) UpdateUser

func (user *User) UpdateUser(ctx context.Context, token *oauth2.Token) error

UpdateUser updates an existing user object

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL