user_models

package
v0.0.0-...-80fd6f0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var API_ENDPOINT string = "https://discord.com/api/v6"
View Source
var DISCORD_CLIENT_ID string = goDotEnvVariable("DISCORD_CLIENT_ID")
View Source
var DISCORD_SECRET string = goDotEnvVariable("DISCORD_SECRET")

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) error

CheckPasswordHash checks password hash and password from user input if they match

func Exchange_code

func Exchange_code(code string) interface{}

func GetAllUsers

func GetAllUsers(db *gorm.DB) (*[]User, error)

GetAllUsers returns a list of all the user

func HashPassword

func HashPassword(password string) (string, error)

HashPassword hashes password from user input

Types

type Discord

type Discord struct {
	gorm.Model
	DiscordId    int    `gorm:"type:integer;unique_index" json:"discord_id"`
	DiscordToken string `gorm:"type:varchar(100);unique_index" json:"discord_token"`
	AvatarHash   string `gorm:"type:varchar(100);unique_index" json:"avatar_hash"`
}

type User

type User struct {
	gorm.Model
	Email    string `gorm:"type:varchar(100);unique_index" json:"email"`
	Name     string `gorm:"size:100;not null"              json:"name"`
	Password string `gorm:"size:100;not null"              json:"password"`
}

func (*User) BeforeSave

func (u *User) BeforeSave() error

BeforeSave hashes user password

func (*User) GetUser

func (u *User) GetUser(db *gorm.DB) (*User, error)

GetUser returns a user based on email

func (*User) GetUserID

func (u *User) GetUserID(id uint, db *gorm.DB) (*User, error)

func (*User) Prepare

func (u *User) Prepare()

func (*User) SaveUser

func (u *User) SaveUser(db *gorm.DB) (*User, error)

func (*User) Validate

func (u *User) Validate(action string) error

Jump to

Keyboard shortcuts

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