user

package
v0.0.0-...-c86e3d9 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewUserRepositoryImpl

func NewUserRepositoryImpl(dbConn *sql.DB)

NewUserRepositoryImpl creates new UserImpl

Types

type RequestRegister

type RequestRegister struct {
	Username string `json:"username"`
	Password string `json:"password"`
	Email    string `json:"email"`
}

type Role

type Role uint8
const (
	OPERATOR     Role = 0x1
	ADMIN        Role = 0x1 << 1
	SYSTEM_ADMIN Role = 0x1 << 2
)

func (Role) IsAdmin

func (r Role) IsAdmin() bool

func (Role) IsOperator

func (r Role) IsOperator() bool

func (Role) IsSystemAdmin

func (r Role) IsSystemAdmin() bool

type User

type User struct {
	Username string `json:"username"`
	Email    string `json:"email"`
	Password string `json:"-"` // here is just for example
	Role     Role   `json:"role"`
}

type UserRepository

type UserRepository interface {
	GetUserFromUsername(string) (*User, error)
	CreateAccount(*User) error
}

UserRepository functions for user repository

type UserRepositoryImpl

type UserRepositoryImpl struct {
	DbConn *sql.DB
}

UserRepositoryImpl struct for db connection

var UserImpl *UserRepositoryImpl

func (*UserRepositoryImpl) Close

func (r *UserRepositoryImpl) Close()

Close the DB connection

func (*UserRepositoryImpl) CreateAccount

func (r *UserRepositoryImpl) CreateAccount(userInput RequestRegister) (err error)

CreateAccount method for create an account with role operator

func (*UserRepositoryImpl) GetUserFromUsername

func (r *UserRepositoryImpl) GetUserFromUsername(username string) (*User, error)

GetUserFromUsername method for retrieve user from bdd

Jump to

Keyboard shortcuts

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