store

package
Version: v0.0.0-...-f68c35f Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2021 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseConnection

func CloseConnection(tb testing.TB, store *SqlStore)

Types

type PrefixedMigration

type PrefixedMigration struct {
	*bindata.Bindata
	// contains filtered or unexported fields
}

func (*PrefixedMigration) ReadDown

func (pm *PrefixedMigration) ReadDown(version uint) (io.ReadCloser, string, error)

func (*PrefixedMigration) ReadUp

func (pm *PrefixedMigration) ReadUp(version uint) (io.ReadCloser, string, error)

type RoleStore

type RoleStore interface {
	CreateRole(role *model.Role) (*model.Role, error)
	GetRoleByName(name string) (*model.Role, error)
	UserHasRole(userID, roleID string) (bool, error)
	UserHasRoleByName(userID, roleName string) (bool, error)
	AddUserRole(userID, roleID string) error
	DeleteUserRole(userID, roleID string) error
}

type SessionStore

type SessionStore interface {
	CreateSession(session *model.Session) (*model.Session, error)
	GetSession(idOrToken string) (*model.Session, error)
	DeleteSession(id string) error
	DeleteSessionsForUser(userID string) error
}

type SqlRoleStore

type SqlRoleStore struct {
	*SqlStore
}

func (*SqlRoleStore) AddUserRole

func (s *SqlRoleStore) AddUserRole(userID, roleID string) error

func (*SqlRoleStore) CreateRole

func (s *SqlRoleStore) CreateRole(role *model.Role) (*model.Role, error)

CreateRole inserts a new role.

func (*SqlRoleStore) DeleteUserRole

func (s *SqlRoleStore) DeleteUserRole(userID, roleID string) error

func (*SqlRoleStore) GetRoleByName

func (s *SqlRoleStore) GetRoleByName(name string) (*model.Role, error)

GetRoleByName returns the role entity for the provided name.

func (*SqlRoleStore) UserHasRole

func (s *SqlRoleStore) UserHasRole(userID, roleID string) (bool, error)

func (*SqlRoleStore) UserHasRoleByName

func (s *SqlRoleStore) UserHasRoleByName(userID, roleName string) (bool, error)

type SqlSessionStore

type SqlSessionStore struct {
	*SqlStore
}

func (*SqlSessionStore) CreateSession

func (s *SqlSessionStore) CreateSession(session *model.Session) (*model.Session, error)

CreateSession inserts a new session.

func (*SqlSessionStore) DeleteSession

func (s *SqlSessionStore) DeleteSession(id string) error

DeleteSession deletes a session by ID.

func (*SqlSessionStore) DeleteSessionsForUser

func (s *SqlSessionStore) DeleteSessionsForUser(userID string) error

DeleteSessionsForUser deletes all the sessions for a user

func (*SqlSessionStore) GetSession

func (s *SqlSessionStore) GetSession(idOrToken string) (*model.Session, error)

GetSession fetches the given session by id or token. Deletes and does not return expired sessions.

type SqlStore

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

func MakeTestStore

func MakeTestStore(tb testing.TB, logger log.FieldLogger) *SqlStore

func New

func New(dsn string, tablePrefix string, logger logrus.FieldLogger) (*SqlStore, error)

New constructs a new instance of SqlStore.

func (*SqlStore) Initialize

func (s *SqlStore) Initialize() error

Initialize imports initial values

func (*SqlStore) Migrate

func (s *SqlStore) Migrate() error

func (*SqlStore) Role

func (s *SqlStore) Role() RoleStore

func (*SqlStore) Session

func (s *SqlStore) Session() SessionStore

func (*SqlStore) Token

func (s *SqlStore) Token() TokenStore

func (*SqlStore) User

func (s *SqlStore) User() UserStore

type SqlStoreStores

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

type SqlTokenStore

type SqlTokenStore struct {
	*SqlStore
}

func (*SqlTokenStore) CleanupTokenStore

func (s *SqlTokenStore) CleanupTokenStore(expiryTimeMillis int64)

CleanupTokenStore removes tokens that are past the defined expiry time.

func (*SqlTokenStore) CreateToken

func (s *SqlTokenStore) CreateToken(token *model.Token) (*model.Token, error)

CreateToken inserts a new token.

func (*SqlTokenStore) DeleteToken

func (s *SqlTokenStore) DeleteToken(tokenValue string) error

DeleteToken deletes a token.

func (*SqlTokenStore) DeleteTokensByEmail

func (s *SqlTokenStore) DeleteTokensByEmail(email, tokenType string) error

DeleteTokensByEmail deletes all the tokes, of one type, belonging to the passed email

func (*SqlTokenStore) GetToken

func (s *SqlTokenStore) GetToken(tokenValue string) (*model.Token, error)

GetToken fetches the given token by token value.

func (*SqlTokenStore) GetTokensByEmail

func (s *SqlTokenStore) GetTokensByEmail(email, tokenType string) ([]*model.Token, error)

GetTokensByEmail fetches the tokens for the passed email

type SqlUserStore

type SqlUserStore struct {
	*SqlStore
}

func (*SqlUserStore) CreateUser

func (s *SqlUserStore) CreateUser(user *model.User) (*model.User, error)

CreateUser inserts a new user.

func (*SqlUserStore) GetUser

func (s *SqlUserStore) GetUser(id string) (*model.User, error)

GetUser fetches the given user by id.

func (*SqlUserStore) GetUserByEmail

func (s *SqlUserStore) GetUserByEmail(email string) (*model.User, error)

GetUserByEmail fetches the given user by email.

func (*SqlUserStore) UnverifyEmail

func (s *SqlUserStore) UnverifyEmail(id, email string) error

UnverifyEmail updates a user's email and marks it as unverified.

func (*SqlUserStore) UpdatePassword

func (s *SqlUserStore) UpdatePassword(id, password string) error

UpdatePassword accepts a plaintext password value, hashes it, and saves it as the new password for a given user.

func (*SqlUserStore) UpdateUser

func (s *SqlUserStore) UpdateUser(user *model.User) error

UpdateUser updates the given user.

func (*SqlUserStore) UpdateUserState

func (s *SqlUserStore) UpdateUserState(userID string, state string) error

func (*SqlUserStore) VerifyEmail

func (s *SqlUserStore) VerifyEmail(id, email string) error

VerifyEmail updates a user's email and marks it as verified.

type Store

type Store interface {
	Role() RoleStore
	Session() SessionStore
	Token() TokenStore
	User() UserStore
}

type StoreTestHelper

type StoreTestHelper struct {
	SqlStore *SqlStore
}

func SetupStoreTestHelper

func SetupStoreTestHelper(t *testing.T) *StoreTestHelper

func (*StoreTestHelper) TearDown

func (th *StoreTestHelper) TearDown(t *testing.T)

type TokenStore

type TokenStore interface {
	CreateToken(token *model.Token) (*model.Token, error)
	GetToken(tokenValue string) (*model.Token, error)
	GetTokensByEmail(email, tokenType string) ([]*model.Token, error)
	DeleteToken(tokenValue string) error
	DeleteTokensByEmail(email, tokenType string) error
	CleanupTokenStore(expiryTimeMillis int64)
}

type UserStore

type UserStore interface {
	CreateUser(user *model.User) (*model.User, error)
	GetUser(id string) (*model.User, error)
	GetUserByEmail(email string) (*model.User, error)
	VerifyEmail(id, email string) error
	UnverifyEmail(id, email string) error
	UpdatePassword(id, password string) error
	UpdateUser(user *model.User) error
	UpdateUserState(userID string, state string) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL