Documentation ¶
Index ¶
- Constants
- Variables
- func AuthByCookie(handlerFunc echo.HandlerFunc) echo.HandlerFunc
- func Dashboard(ctx *AdminContext) error
- func HTMLError(e error, ctx echo.Context)
- func JSONError(e error, ctx echo.Context)
- func Login(ctx *AdminContext) error
- func Logout(ctx *AdminContext) error
- func Path(paths ...string) string
- func WrapHandler(h AdminHandler) echo.HandlerFunc
- type Admin
- type AdminContext
- type AdminHandler
- type AssetSource
- type Config
- type DBConfig
- type Data
- type Renderer
- type Response
- type Token
- type TokenRepository
- type TokenType
- type User
- type UserFilter
- type UserRepository
- type UserStatus
- type UserUseCase
- type ViewData
Constants ¶
View Source
const (
DefaultAssetsPath = "./assets"
)
Variables ¶
View Source
var ( DashboardURL = "/" LoginURL = "/login" LogoutURL = "/logout" AccessCookieName = "auth_token" ErrContextNotConfigured = errors.New("admin context not configured") )
View Source
var ( ErrWrongPassword = errors.New("wrong password") ErrUserNotFound = errors.New("user not found") ErrTokenNotFound = errors.New("token not found") )
View Source
var (
DataContextKey = "data_context"
)
Functions ¶
func AuthByCookie ¶
func AuthByCookie(handlerFunc echo.HandlerFunc) echo.HandlerFunc
func Dashboard ¶
func Dashboard(ctx *AdminContext) error
func Login ¶
func Login(ctx *AdminContext) error
func Logout ¶
func Logout(ctx *AdminContext) error
func WrapHandler ¶
func WrapHandler(h AdminHandler) echo.HandlerFunc
Types ¶
type Admin ¶
type Admin struct { *Config // contains filtered or unexported fields }
func (*Admin) LoadAssets ¶
type AdminContext ¶
type AdminContext struct { echo.Context // contains filtered or unexported fields }
func (*AdminContext) Ctx ¶
func (c *AdminContext) Ctx() context.Context
func (*AdminContext) Data ¶
func (c *AdminContext) Data() *Data
func (AdminContext) URL ¶
func (c AdminContext) URL(path string) string
func (*AdminContext) User ¶
func (c *AdminContext) User() *User
func (*AdminContext) UserCase ¶
func (c *AdminContext) UserCase() UserUseCase
type AdminHandler ¶
type AdminHandler func(ctx *AdminContext) error
type AssetSource ¶
type Config ¶
type Token ¶
type TokenRepository ¶
type User ¶
type User struct { ID int64 `db:"id" json:"id"` Login string `db:"login" json:"login"` Password string `db:"password" json:"password"` Status UserStatus `db:"status" json:"status"` Name string `db:"name" json:"name"` DTCreated time.Time `db:"dt_created" json:"dt_created"` DTUpdated time.Time `db:"dt_updated" json:"dt_updated"` DTLastLogged time.Time `db:"dt_last_logged" json:"dt_last_logged"` PasswordIsEncoded bool `db:"password_is_encoded" json:"-"` Current bool `db:"-" json:"-"` }
type UserFilter ¶
type UserFilter struct { Name string Login string Status UserStatus Limit, Offset int }
type UserRepository ¶
type UserStatus ¶
type UserStatus string
const ( UserNew UserStatus = "new" UserActive UserStatus = "active" UserBlocked UserStatus = "blocked" UserContextKey = "user_context" )
func (UserStatus) IsValid ¶
func (status UserStatus) IsValid() bool
type UserUseCase ¶
type UserUseCase interface { SearchByLogin(ctx context.Context, login string) (*User, error) ComparePassword(user *User, password string) (bool, error) CreateAuthToken(ctx context.Context, user *User) (*Token, error) SetLastLogged(ctx context.Context, user *User) error SearchToken(ctx context.Context, token string) (*Token, error) }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.