user

package
v0.0.0-...-35e313c Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const Type string = "User"

Type of Model

Variables

View Source
var (
	EmailValidationCompiledRegex = regexp.MustCompile(emailValidatinRegex)
)

TODO : ADD constraints for password special characters

Functions

func Activate

func Activate()

Activate activate the user

func CompareHashAndPassword

func CompareHashAndPassword(hash string, password string) bool

CompareHashAndPassword compares password and hashes

func Create

func Create(db sqlbuilder.Database, userObj *User, orgName string) (string, int, error)

Create create new user

func Exists

func Exists(DB sqlbuilder.Database, UID ID) (bool, error)

Exists check whether user exists using its id

func GenerateHashedPassword

func GenerateHashedPassword(password string) string

GenerateHashedPassword generates hashes for the password

func Inactivate

func Inactivate()

Inactivate inactivate the user

Types

type ID

type ID string

ID userID

func Authenticate

func Authenticate(DB sqlbuilder.Database, userName string, password string) (ID, bool, error)

Authenticate authenticates user by username and password

type Org

type Org struct {
	UserID ID     `json:"user_id,omitempty" db:"USER_ID"`
	OrgID  org.ID `json:"org_id,omitempty" db:"ORG_ID"`
}

Org type

type User

type User struct {
	ID           ID                           `json:"user_id,omitempty" db:"ID"`
	UserName     string                       `json:"user_name,omitempty" db:"USER_NAME"`
	FirstName    string                       `json:"first_name,omitempty" db:"FIRST_NAME"`
	LastName     string                       `json:"last_name,omitempty" db:"LAST_NAME"`
	SuperUser    int8                         `json:"is_super_user,omitempty" db:"IS_SUPER"`
	Staff        int8                         `json:"is_staff,omitempty" db:"IS_STAFF"`
	Email        cryptography.EncryptedString `json:"email,omitempty" db:"EMAIL"`
	DOJ          time.Time                    `json:"doj,omitempty" db:"DOJ"`
	Active       int8                         `json:"active,omitempty" db:"ACTIVE"`
	PasswordHash string                       `json:"password_hash,omitempty" db:"PASSWORD_HASH"`
}

User user type

func AuthenticateByID

func AuthenticateByID(DB sqlbuilder.Database, UID ID) (*User, bool, error)

AuthenticateByID checks whether user is available by user id if user is present , return user

func ByID

func ByID(DB sqlbuilder.Database, UID ID, active bool) (*User, string, int, error)

ByID get the user using user id

func (*User) IsActive

func (u *User) IsActive() bool

IsActive checks whether user is active

func (*User) IsStaff

func (u *User) IsStaff() bool

IsStaff checks whether user is staff

func (*User) IsSuperUser

func (u *User) IsSuperUser() bool

IsSuperUser checks whether user is super user

Jump to

Keyboard shortcuts

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