models

package
v0.0.0-...-f8ea5e8 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	USER_ROLE  = "USER"
	ADMIN_ROLE = "ADMIN"
)

Variables

View Source
var DefaultUserPicture = []byte{} /* 2116 elements not displayed */

Functions

func ClearDB

func ClearDB()

func DeleteUser

func DeleteUser(userID uint) error

func GetUserRoles

func GetUserRoles(userId uint) ([]string, error)

GetUserRoles return user roles by user id

func HashAndSalt

func HashAndSalt(password string, config *helpers.Config) (string, error)

func InitDB

func InitDB(config *helpers.Config) (*sqlx.DB, error)

InitDB connect to database, migrate tables

Types

type FeedBack

type FeedBack struct {
	ID        uint      `db:"id" json:"id"`
	CreatedAt time.Time `db:"created_at" json:"created_at"`
	Message   string    `db:"message" json:"message"`
}

type OAuthRegister

type OAuthRegister struct {
	ID              string `db:"id" json:"id"`
	OAuthName       string `db:"oauth_name" json:"oauth_name"`
	UserInServiceID string `db:"user_id" json:"-"`

	Nick    string `db:"nick" json:"nick"`
	Name    string `db:"name" json:"name"`
	Email   string `db:"email" json:"email"`
	Picture string `db:"picture" json:"picture"`
}

OAuthRegister oauth registration info

func GetOAuthRegister

func GetOAuthRegister(registerID string) (OAuthRegister, error)

GetOAuthRegister return OAuthRegister by registration id

type PublicUser

type PublicUser struct {
	ID    uint     `db:"id" json:"id"`
	Nick  string   `db:"nick" json:"nick"`
	Name  string   `db:"name" json:"name"`
	Roles []string `db:"roles" json:"roles"`
}

PublicUser public user model. This model can see all users

type User

type User struct {
	ID        uint      `db:"id" json:"id"`
	CreatedAt time.Time `db:"created_at" json:"created_at"`

	Email string `db:"email" json:"email"`
	Nick  string `db:"nick" json:"nick"`
	Name  string `db:"name" json:"name"`

	PasswordHash string `db:"password_hash" json:"-"`
	RefreshToken string `db:"refresh_token" json:"-"`

	Roles []string `db:"roles" json:"roles"`
}

User model. This model can see dev and user

func GetUser

func GetUser(userId uint) (User, error)

GetUser return user by user id

func GetUserByNick

func GetUserByNick(nick string) (User, error)

GetUserByNick return user by user nick

func (User) ToPublic

func (user User) ToPublic() PublicUser

type UserAccount

type UserAccount struct {
	ID uint `db:"id" json:"-"`

	UserID uint `db:"user_id" json:"-"`

	Service     string `db:"service" json:"service"`
	InServiceID string `db:"in_service_id" json:"in_service_id"`
}

UserAccount oauth accounts connected to user

func GetUserAccount

func GetUserAccount(userInServiceID string, oauthName string) (UserAccount, error)

GetUserAccount return UserAccount by userInServiceId and oauth service name

type UserPicture

type UserPicture struct {
	UserID uint   `db:"user_id"`
	Image  []byte `db:"image"`
}

UserPicture user picture

Jump to

Keyboard shortcuts

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