gin-sample: github.com/yamnikov-oleg/gin-sample/models/user Index | Files

package user

import "github.com/yamnikov-oleg/gin-sample/models/user"

Index

Package Files

user.go

Constants

const (
    Sess_UserIdKey  = "user_id"
    Ctx_LoggedInKey = "logged_in"
    Ctx_UserPtrKey  = "user"
)

Variables

var (
    NameTakenErr   = errors.New("Имя пользователя уже занято.")
    LoginFailedErr = errors.New("" /* 142 byte string literal not displayed */)
    DbErr          = models.NewParamError("Ошибка базы данных: %v")
)

func Hash Uses

func Hash(password string) string

func Logout Uses

func Logout(c *gin.Context)

type User Uses

type User struct {
    gorm.Model
    Name         string `sql:"unique_index"`
    PasswordHash string
}

func Create Uses

func Create(name string, password string) (*User, error)

func Current Uses

func Current(c *gin.Context) (u *User, loggedIn bool)

func Find Uses

func Find(id uint) (*User, bool)

func FindByName Uses

func FindByName(name string) (*User, bool)

func Login Uses

func Login(c *gin.Context, name string, password string) (*User, error)

func (*User) AutoLogin Uses

func (u *User) AutoLogin(c *gin.Context)

Package user imports 7 packages (graph) and is imported by 2 packages. Updated 2018-04-16. Refresh now. Tools for package owners.