UserService

package
v0.0.0-...-5039b75 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FindBySubSql = `` /* 126-byte string literal not displayed */
View Source
var FindByUsernameSql = `
    SELECT id, sub, username, created_at, updated_at, deleted_at
    FROM users u
    WHERE username = ?
`
View Source
var FindPasswordByUsernameSql = `
    SELECT id, sub, username, password, created_at, updated_at, deleted_at
    FROM users u
    WHERE username = ?
`
View Source
var UserInsertSql = `
INSERT INTO users(username,password,id)
VALUES ( ?,?,UNHEX( REPLACE( ?,'-','' )));
`
View Source
var UsernameAvailableSql = `
	SELECT COUNT(*) = 0
	FROM (
		SELECT 1
		FROM users u
		WHERE username = ?
	    LIMIT 1
	) AS found;
`

Functions

This section is empty.

Types

type Bundlable

type Bundlable struct{}

Bundlable adheres to Services.IBundlable and allows the service to be bundled

func (Bundlable) CreateService

func (h Bundlable) CreateService(appCtx AppContext.Context) (interface{}, error)

CreateService is a copy-pasta property

func (Bundlable) ServiceName

func (h Bundlable) ServiceName() string

ServiceName Return the name of the service as it is defined in Services.Bundle

type IUserSvc

type IUserSvc interface {
	Create(username string, password string) (string, error)
	FindByUn(username string, user models.User) (*models.User, error)
	FindBySub(sub string, user models.User) (*models.User, error)
	UsernameAvailable(username string) (bool, error)
	ValidatePassword(username string, password string, user models.User) (*models.User, error)
}

type UserSvc

type UserSvc struct {
	AppCtx AppContext.Context
}

UserSvc adheres to IUserSvc

func (*UserSvc) Create

func (h *UserSvc) Create(username string, password string) (string, error)

func (*UserSvc) FindBySub

func (h *UserSvc) FindBySub(sub string, user models.User) (*models.User, error)

func (*UserSvc) FindByUn

func (h *UserSvc) FindByUn(username string, user models.User) (*models.User, error)

func (*UserSvc) UsernameAvailable

func (h *UserSvc) UsernameAvailable(username string) (bool, error)

func (*UserSvc) ValidatePassword

func (h *UserSvc) ValidatePassword(username string, password string, user models.User) (*models.User, error)

Jump to

Keyboard shortcuts

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