models

package
v0.0.0-...-5b087d4 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2017 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthUser

type AuthUser struct {
	*User
	Admin bool `json:"admin"`
}

AuthUser represents a user account for private visibility (used for login and update response) Its MarshalJSON function will expose its role.

func (*AuthUser) MarshalJSON

func (u *AuthUser) MarshalJSON() ([]byte, error)

type Post

type Post struct {
	ID        int            `json:"id"`
	Title     string         `json:"title"`
	Slug      string         `json:"slug"`
	Body      string         `json:"body"`
	UserID    int            `json:"userId"`
	Author    string         `json:"author,omitempty"`
	CreatedAt time.Time      `json:"createdAt"`
	UpdatedAt mysql.NullTime `json:"updatedAt"`
}

func (*Post) MarshalJSON

func (p *Post) MarshalJSON() ([]byte, error)

type User

type User struct {
	ID        int            `json:"id"`
	Name      string         `json:"name"`
	Email     string         `json:"email"`
	Password  string         `json:"password"`
	Admin     bool           `json:"admin"`
	CreatedAt time.Time      `json:"createdAt"`
	UpdatedAt mysql.NullTime `json:"updatedAt"`
}

User represents a user account for public visibility (used for public endpoints) Its MarshalJSON function wont expose its role.

func (*User) CheckPassword

func (u *User) CheckPassword(password string) bool

func (*User) IsAdmin

func (u *User) IsAdmin() bool

func (*User) MarshalJSON

func (u *User) MarshalJSON() ([]byte, error)

TODO: Maybe find a better solution to remove the password when marshalling to json

func (*User) SetPassword

func (u *User) SetPassword(password string)

Jump to

Keyboard shortcuts

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