db

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserAlreadyExists = errors.New("user already exists")
)

Functions

This section is empty.

Types

type CheckRefreshTokenRecord added in v0.3.0

type CheckRefreshTokenRecord struct {
	UserId       uuid.UUID
	RefreshToken string
}

type CloseRecord added in v0.3.0

type CloseRecord struct {
}

type Connection

type Connection interface {
	Close()
	CreateUser(user *UserDB, hash string) error
	UpdateRefreshToken(userId uuid.UUID, refreshToken string, refreshTokenExpireAt time.Time) error
	LoginUser(user *UserDB) error
	CheckRefreshToken(userId uuid.UUID, refreshToken string) error
	UpdatePassword(userId uuid.UUID, password string, hash string) error
	DeleteUser(userId uuid.UUID) error
	DeleteInitUsers() error
}

func NewConnection

func NewConnection() (Connection, error)

type CreateUserRecord added in v0.3.0

type CreateUserRecord struct {
	User *UserDB
	Hash string
}

type DBMock added in v0.3.0

type DBMock struct {
	CloseRecordArray                []*CloseRecord
	CreateUserRecordArray           []*CreateUserRecord
	UpdateRefreshTokenRecordArray   []*UpdateRefreshTokenRecord
	LoginUserRecordArray            []*LoginUserRecord
	CheckRefreshTokenRecordArray    []*CheckRefreshTokenRecord
	UpdatePasswordRecordArray       []*UpdatePasswordRecord
	DeleteUserRecordArray           []*DeleteUserRecord
	DeleteInitUsersRecordArray      []*CloseRecord
	CreateUserResponseArray         []*ErrorResponse
	UpdateRefreshTokenResponseArray []*ErrorResponse
	LoginUserResponseArray          []*ErrorResponse
	CheckRefreshTokenResponseArray  []*ErrorResponse
	UpdatePasswordResponseArray     []*ErrorResponse
	DeleteUserResponseArray         []*ErrorResponse
	DeleteInitUsersResponseArray    []*ErrorResponse
}

func (*DBMock) CheckRefreshToken added in v0.3.0

func (mock *DBMock) CheckRefreshToken(userId uuid.UUID, refreshToken string) error

func (*DBMock) Close added in v0.3.0

func (mock *DBMock) Close()

func (*DBMock) CreateUser added in v0.3.0

func (mock *DBMock) CreateUser(user *UserDB, hash string) error

func (*DBMock) DeleteInitUsers added in v0.7.0

func (mock *DBMock) DeleteInitUsers() error

func (*DBMock) DeleteUser added in v0.3.0

func (mock *DBMock) DeleteUser(userId uuid.UUID) error

func (*DBMock) LoginUser added in v0.3.0

func (mock *DBMock) LoginUser(user *UserDB) error

func (*DBMock) UpdatePassword added in v0.3.0

func (mock *DBMock) UpdatePassword(userId uuid.UUID, password string, hash string) error

func (*DBMock) UpdateRefreshToken added in v0.3.0

func (mock *DBMock) UpdateRefreshToken(userId uuid.UUID, refreshToken string, refreshTokenExpireAt time.Time) error

type DeleteUserRecord added in v0.3.0

type DeleteUserRecord struct {
	UserId uuid.UUID
}

type ErrorResponse added in v0.3.0

type ErrorResponse struct {
	Err error
}

type LoginUserRecord added in v0.3.0

type LoginUserRecord struct {
	User *UserDB
}

type UpdatePasswordRecord added in v0.3.0

type UpdatePasswordRecord struct {
	UserId   uuid.UUID
	Password string
	Hash     string
}

type UpdateRefreshTokenRecord added in v0.3.0

type UpdateRefreshTokenRecord struct {
	UserId               uuid.UUID
	RefreshToken         string
	RefreshTokenExpireAt time.Time
}

type UserDB

type UserDB struct {
	ID        uuid.UUID `db:"id"`
	Password  string    `db:"password"`
	CreatedOn time.Time `db:"created_on"`
	LastLogin time.Time `db:"last_login"`
	InitUser  bool      `db:"init_user"`
}

Jump to

Keyboard shortcuts

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