models

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *pg.DB

DB main database connection

Functions

func CheckConnection

func CheckConnection()

CheckConnection checks if the data base is available

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