user

package
v0.0.0-...-01681b2 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2018 License: MIT Imports: 20 Imported by: 0

README

实现 ssolib 定义的 user 接口

Documentation

Index

Constants

View Source
const (
	// Use ./cmd/bcryptcost tool to find approriate cost
	BCRYPT_COST = 11
)
View Source
const (
	SSOREALMNAME = "sso-mysql"
)

Variables

View Source
var (
	ADMINEMAIL  string
	ADMINPASSWD string
)
View Source
var (
	ErrUserExists   = errors.New("User already exists")
	ErrCodeNotFound = errors.New("Code not found")
)

Functions

func GenericSendMail

func GenericSendMail(ctx *models.Context, to []string, msg []byte) (err error)

func RegisterUser

func RegisterUser(ctx *models.Context, reg UserRegistration, userback iuser.UserBackend) (code string, err error)

func RequestResetPassword

func RequestResetPassword(ctx *models.Context, user *User) error

func ResetPassword

func ResetPassword(ctx *models.Context, user *User, code string, password string) error

Types

type ResetPasswordRequest

type ResetPasswordRequest struct {
	Id             int
	UserId         int    `db:"user_id"`
	ActivationCode string `db:"activation_code"`
	Created        string
}

type User

type User struct {
	Id           int
	Name         string
	FullName     string
	Email        sql.NullString
	PasswordHash []byte `db:"password"`
	Mobile       sql.NullString
	Created      string
	Updated      string
	// contains filtered or unexported fields
}

func ActivateUser

func ActivateUser(ctx *models.Context, code string, userback iuser.UserBackend) (*User, error)

func (*User) GetEmail

func (u *User) GetEmail() string

func (*User) GetFullName

func (u *User) GetFullName() string

func (*User) GetId

func (u *User) GetId() int

func (*User) GetMobile

func (u *User) GetMobile() string

func (*User) GetName

func (u *User) GetName() string

func (*User) GetPasswordHash

func (u *User) GetPasswordHash() []byte

func (*User) GetProfile

func (u *User) GetProfile() iuser.UserProfile

func (*User) GetPublicProfile

func (u *User) GetPublicProfile() iuser.UserProfile

func (*User) GetSub

func (u *User) GetSub() string

func (*User) SetBackend

func (u *User) SetBackend(b iuser.UserBackend)

func (*User) VerifyPassword

func (u *User) VerifyPassword(password []byte) bool

type UserBack

type UserBack struct {
	DB *sqlx.DB
}

func New

func New(dsn string, adminEmail string, adminPasswd string) *UserBack

func (*UserBack) AuthPassword

func (ub *UserBack) AuthPassword(sub, passwd string) (bool, error)

func (*UserBack) AuthPasswordByFeature

func (ub *UserBack) AuthPasswordByFeature(feature, passwd string) (bool, iuser.User, error)

func (*UserBack) CreateUser

func (ub *UserBack) CreateUser(user iuser.User, passwordHashed bool) error

func (*UserBack) DeleteAllActivationCodes

func (ub *UserBack) DeleteAllActivationCodes(ctx context.Context) error

func (*UserBack) DeleteUser

func (ub *UserBack) DeleteUser(user iuser.User) error

func (*UserBack) GetUser

func (ub *UserBack) GetUser(id int) (iuser.User, error)

func (*UserBack) GetUserByEmail

func (ub *UserBack) GetUserByEmail(email string) (iuser.User, error)

func (*UserBack) GetUserByFeature

func (ub *UserBack) GetUserByFeature(f string) (iuser.User, error)

func (*UserBack) GetUserByName

func (ub *UserBack) GetUserByName(name string) (iuser.User, error)

func (*UserBack) InitDatabase

func (ub *UserBack) InitDatabase()

func (*UserBack) InitModel

func (ub *UserBack) InitModel(ctx interface{})

func (*UserBack) ListInactiveUsers

func (ub *UserBack) ListInactiveUsers(ctx context.Context) ([]UserRegistration, error)

func (*UserBack) ListUsers

func (ub *UserBack) ListUsers(ctx context.Context) ([]iuser.User, error)

func (*UserBack) Name

func (ub *UserBack) Name() string

func (*UserBack) SupportedVerificationMethods

func (ub *UserBack) SupportedVerificationMethods() []string

func (*UserBack) UserIdToSub

func (ub *UserBack) UserIdToSub(id int) string

func (*UserBack) UserSubToId

func (ub *UserBack) UserSubToId(sub string) (int, error)

type UserProfile

type UserProfile struct {
	Name     string `json:"name"`
	FullName string `json:"fullname"`
	Email    string `json:"email"`
	Mobile   string `json:"mobile"`
}

func (*UserProfile) GetEmail

func (p *UserProfile) GetEmail() string

func (*UserProfile) GetMobile

func (p *UserProfile) GetMobile() string

func (*UserProfile) GetName

func (p *UserProfile) GetName() string

type UserRegistration

type UserRegistration struct {
	Id             int
	Name           string
	FullName       string
	Email          sql.NullString
	Password       string
	Mobile         sql.NullString
	ActivationCode string `db:"activation_code"`
	Created        string
}

Jump to

Keyboard shortcuts

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