models

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 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 {
	ID          int64     `pg:",pk" json:"id"`
	Password    string    `pg:"type:varchar(128),notnull" json:"-"`
	LastLogin   time.Time `json:"-"`
	Username    string    `pg:"type:varchar(150),notnull,unique" json:"username"`
	FirstName   string    `pg:"type:varchar(30),notnull" json:"-"`
	LastName    string    `pg:"type:varchar(30),notnull" json:"-"`
	Email       string    `pg:"type:varchar(254),notnull" json:"email"`
	IsSuperuser bool      `pg:",notnull" json:"-"`
	IsStaff     bool      `pg:",notnull" json:"-"`
	IsActive    bool      `pg:",notnull" json:"-"`
	DateJoined  time.Time `pg:",notnull" json:"-"`
	// contains filtered or unexported fields
}

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