models

package
v0.0.0-...-ea050f3 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2015 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Privatekey = `` /* 1674-byte string literal not displayed */

	Tokenduration = time.Hour * 24
)

For a while, we hardcode this value, but we need use true values

Variables

View Source
var (
	DB_URL  string = "localhost"
	DB_NAME string = "mstock"
)

Functions

func ParseToken

func ParseToken(token string) (*jwt.Token, error)

Get a object token from a string hash that represent the token

Types

type Token

type Token struct {
	Hash   string    `json:"token"`
	Expire time.Time `json:"expire"`
}

With this data we could authentic the user

func GenerateToken

func GenerateToken(d ...interface{}) (Token, error)

Create and return a object Token, this need one o more strings for generate a hash

type User

type User struct {
	IdUser    string    `json:"id_user"`
	Name      string    `json:"name"`
	Pass      string    `json:"pass"`
	Email     string    `json:"email"`
	LastLogin time.Time `json:"last_login"`
	CreatedAt time.Time `json:"create_at"`
	UpdateAt  time.Time `json:"update"`
	Token     Token     `json:"token"`
}

Data representing the application user, is the structure that is going to relate all application data, to perform effective monitoring of user actions.

func FindUsers

func FindUsers(email string) ([]User, error)

We are going to search for users in the database, given through an e-mail

func (User) Delete

func (u User) Delete() error

It will remove the user associated with that ID

func (User) Get

func (u User) Get() (User, error)

We will return the user data associated with ID

func (User) Save

func (u User) Save() error

Updated user data, and if it does not exist create a new one

func (User) Valid

func (u User) Valid() bool

We will check if the user data are valid

Jump to

Keyboard shortcuts

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