models

package
v0.0.0-...-5217b34 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2019 License: MIT Imports: 4 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthMethod

type AuthMethod int

AuthMethod is a authentication mark

const (
	// LOCAL authentication
	LOCAL AuthMethod = 0
	// GOOGLE authentication
	GOOGLE AuthMethod = 1
	// FACEBOOK authentication
	FACEBOOK AuthMethod = 2
)

type Claims

type Claims struct {
	ID int `json:"id"`
	jwt.StandardClaims
}

Claims is the jwt struct

type Configuration

type Configuration struct {
	Port                       string `json:"app_port" env:"APP_PORT"`
	DatabaseName               string `json:"database_name" env:"DATABASE_NAME"`
	DatabaseEndPoint           string `json:"database_endpoint" env:"DATABASE_ENDPOINT"`
	DatabaseUser               string `json:"database_user" env:"DATABASE_USER"`
	DatabasePassword           string `json:"database_password" env:"DATABASE_PASSWORD"`
	MailFrom                   string `json:"mail_from" env:"MAIL_FROM"`
	MailSubjectConfirmAccount  string `json:"mail_subject_confirm_account" env:"MAIL_SUBJECT_CONFIRM_ACCOUNT"`
	MailSubjectRecoveryAccount string `json:"mail_subject_recovery_account" env:"MAIL_SUBJECT_RECOVERY_ACCOUNT"`
	MailConfirmationLink       string `json:"mail_confirmation" env:"MAIL_CONFIRMATION"`
	MailSuccessRedirect        string `json:"mail_success" env:"MAIL_SUCCESS"`
	MailFailedRedirect         string `json:"mail_failed" env:"MAIL_FAILED"`
	MailPassword               string `json:"mail_password" env:"MAIL_PASSWORD"`
	MailAddress                string `json:"mail_address" env:"MAIL_ADDRESS"`
	SMTPAddress                string `json:"mail_smtp" env:"MAIL_SMTP"`
	SMTPPort                   string `json:"mail_smtp_port" env:"MAIL_SMTP_PORT"`

	AccessTokenValidityTime  time.Duration `json:"access_token_validity_time" env:"ACCESS_TOKEN_VALIDITY_TIME"`
	RefreshTokenValidityTime time.Duration `json:"refresh_token_validity_time" env:"REFRESH_TOKEN_VALIDITY_TIME"`
}

Configuration struct is used to load configuration from file or environnement

type LoginPayload

type LoginPayload struct {
	Username string `json:"username" binding:"required" example:"sankamille"`
	Password string `json:"password" binding:"required" example:"password123"`
}

LoginPayload is the login model

type LoginResponsePayload

type LoginResponsePayload struct {
	Success      bool   `json:"success" binding:"required"`
	Message      string `json:"message" binding:"required"`
	Token        string `json:"token" binding:"required"`
	User         User   `json:"user" binding:"required"`
	RefreshToken string `json:"refresh-token" binding:"required"`
}

LoginResponsePayload is the login response

type RecoveryPayload

type RecoveryPayload struct {
	Email string `json:"email" binding:"required" exemple:"luc.brulet@epitech.eu"`
}

RecoveryPayload is the recovery model

type RegisterPayload

type RegisterPayload struct {
	Username string `json:"username" binding:"required" example:"sankamille"`
	Email    string `json:"email" binding:"required" example:"luc.brulet@epitech.eu"`
	Password string `json:"password" binding:"required" example:"password123"`
}

RegisterPayload is the register model

type RegisterResponsePayload

type RegisterResponsePayload struct {
	Success bool   `json:"success" binding:"required"`
	Message string `json:"message" binding:"required"`
	Token   string `json:"token" binding:"required"`
	User    User   `json:"user" binding:"required"`
}

RegisterResponsePayload is the register response

type ResponsePayload

type ResponsePayload struct {
	Success bool        `json:"success" binding:"required"`
	Message interface{} `json:"message" binding:"required"`
}

ResponsePayload is the api response

type Template

type Template struct {
	Email        string
	Username     string
	ConfirmEmail string
}

Template struct is used to fill to mail template

type TemplateRecovery

type TemplateRecovery struct {
	Email    string
	Username string
	Password string
}

TemplateRecovery struct is used to fill the mail recovery template

type User

type User struct {
	ID         int        `json:"id"`
	Username   string     `json:"username" binding:"required"`
	Email      string     `json:"email" binding:"required"`
	Password   string     `json:"-"`
	Admin      bool       `json:"admin"`
	Verified   bool       `json:"verified"`
	AuthMethod AuthMethod `json:"-" binding:"required"`
	// contains filtered or unexported fields
}

User is a struct about a user

func (*User) Delete

func (u *User) Delete(db *sql.DB) error

Delete deletes the User from the database.

func (*User) Deleted

func (u *User) Deleted() bool

Deleted provides information if the User has been deleted from the database.

func (*User) Exists

func (u *User) Exists() bool

Exists determines if the User exists in the database.

func (*User) Insert

func (u *User) Insert(db *sql.DB) error

Insert inserts the User to the database.

func (*User) Save

func (u *User) Save(db *sql.DB) error

Save saves the User to the database.

func (*User) Update

func (u *User) Update(db *sql.DB) error

Update updates the User in the database.

type UserUpdate

type UserUpdate struct {
	Username string `json:"username" exemple:"sankamille"`
	Email    string `json:"email" exemple:""`
	Password string `json:"password" exemple:"test"`
	Admin    bool   `json:"admin"`
	Verified bool   `json:"verified"`
}

UserUpdate is a struct used to update a user

Jump to

Keyboard shortcuts

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