customer

package
v0.0.0-...-046b0b7 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2014 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ModifyOrganization

func ModifyOrganization(name string, organization Organization) error

ModifyOrganization modify organization

func RemoveOrganization

func RemoveOrganization(name string) error

RemoveOrganization remove organization

Types

type Organization

type Organization struct {
	Name   string   `json:"name" bson:"_id"`
	Teams  []Team   `json:"teams" bson:"teams"`
	Admins []string `json:"admins" bson:"admins"`
}

Organization holds its name, teams and admins

func DetailOrganization

func DetailOrganization(name string) (Organization, error)

DetailOrganization detail organization

func NewOrganization

func NewOrganization(organization Organization) (Organization, error)

NewOrganization create new organization

type OrganizationList

type OrganizationList []Organization

OrganizationList holds a list of organization

func ListOrganizations

func ListOrganizations() (OrganizationList, error)

ListOrganizations list organizations

type Team

type Team struct {
	Name  string   `json:"name" bson:"name"`
	Users []string `json:"users" bson:"users"`
}

Team holds its name and users list

type User

type User struct {
	Name      string    `bson:"name"`
	Email     string    `bson:"_id"`
	Password  string    `bson:"password"`
	APIKey    string    `bson:"apikey"`
	Created   time.Time `bson:"created"`
	LastLogin time.Time `bson:"lastlogin"`
}

User represent a system user

func DetailUser

func DetailUser(email string) (User, error)

DetailUser detail user

func GetUserByAPIKey

func GetUserByAPIKey(APIKey string) (User, error)

GetUserByAPIKey find user by APIKey

func GetUserByEmail

func GetUserByEmail(email string) (User, error)

GetUserByEmail find user by Email

func NewUser

func NewUser(name, email, password string) (User, error)

NewUser create a new user, check email, encrypt pass and generate APIKey

func (*User) EncryptPassword

func (u *User) EncryptPassword()

EncryptPassword before store on DB encrypt user password

func (*User) GenerateAPIKey

func (u *User) GenerateAPIKey()

GenerateAPIKey for new users

func (*User) ValidateEmail

func (u *User) ValidateEmail() (bool, error)

ValidateEmail check if email is valid

func (*User) ValidatePassword

func (u *User) ValidatePassword(password string) error

ValidatePassword check if password is valid

Jump to

Keyboard shortcuts

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