models

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateUser

func CreateUser(username, password, firstName, lastName, email string, isStaff, isSuperuser bool) error

CreateUser creates a new active user with a given password

Types

type SessionData

type SessionData struct {
	ID             int64
	Username       string
	Email          string
	IsStaff        bool
	SessionVersion string
}

SessionData type to store user data in session

type User

type User struct {
	bun.BaseModel `bun:"auth_user"`
	ID            int64     `bun:",pk" json:"id"`
	Password      string    `bun:"type:varchar(128),notnull" json:"-"`
	LastLogin     time.Time `json:"-"`
	Username      string    `bun:"type:varchar(150),notnull,unique" json:"username"`
	FirstName     string    `bun:"type:varchar(30),notnull" json:"-"`
	LastName      string    `bun:"type:varchar(30),notnull" json:"-"`
	Email         string    `bun:"type:varchar(254),notnull" json:"email"`
	IsSuperuser   bool      `bun:",notnull" json:"-"`
	IsStaff       bool      `bun:",notnull" json:"-"`
	IsActive      bool      `bun:",notnull" json:"-"`
	DateJoined    time.Time `bun:",notnull" json:"-"`
}

User type

func Auth

func Auth(username, password string) (*User, error)

Auth authenticates user (checks if it exists with a given password)

func GetUsers

func GetUsers() ([]User, error)

GetUsers todo

Jump to

Keyboard shortcuts

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