models

package
v0.0.0-...-87ef350 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateToken

func CreateToken(res http.ResponseWriter, req *http.Request, userID uint) error

CreateToken : creates a new jwt token

func DeleteToken

func DeleteToken(res http.ResponseWriter, req *http.Request) error

DeleteToken : creates a new empty token

func ExtractToken

func ExtractToken(r *http.Request) string

ExtractToken : extract token info from request

func ExtractTokenID

func ExtractTokenID(r *http.Request) (uint32, error)

ExtractTokenID : extract user id info from jwt token

func Pretty

func Pretty(data interface{})

Pretty display the claims licely in the terminal

func TokenValid

func TokenValid(r *http.Request) error

TokenValid : check token validity

Types

type Config

type Config struct {
	SocialCallbackBaseURL     string
	ServerPort                string
	CookieStore               string
	JwtTokenSecret            string
	TwitterKey                string
	TwitterSecret             string
	FacebookKey               string
	FacebookSecret            string
	FitbitKey                 string
	FitbitSecret              string
	GoogleKey                 string
	GoogleSecret              string
	GplusKey                  string
	GplusSecret               string
	GithubKey                 string
	GithubSecret              string
	SpotifyKey                string
	SpotifySecret             string
	LinkedinKey               string
	LinkedinSecret            string
	LineKey                   string
	LineSecret                string
	LastfmKey                 string
	LastfmSecret              string
	TwitchKey                 string
	TwitchSecret              string
	DropboxKey                string
	DropboxSecret             string
	DigitaloceanKey           string
	DigitaloceanSecret        string
	BitbucketKey              string
	BitbucketSecret           string
	InstagramKey              string
	InstagramSecret           string
	IntercomKey               string
	IntercomSecret            string
	BoxKey                    string
	BoxSecret                 string
	SalesforceKey             string
	SalesforceSecret          string
	SeatalkKey                string
	SeatalkSecret             string
	AmazonKey                 string
	AmazonSecret              string
	YammerKey                 string
	YammerSecret              string
	OnedriveKey               string
	OnedriveSecret            string
	AzureadKey                string
	AzureadSecret             string
	MicrosoftonlineKey        string
	MicrosoftonlineSecret     string
	BattlenetKey              string
	BattlenetSecret           string
	EveonlineKey              string
	EveonlineSecret           string
	KakaoKey                  string
	KakaoSecret               string
	YahooKey                  string
	YahooSecret               string
	TypetalkKey               string
	TypetalkSecret            string
	SlackKey                  string
	SlackSecret               string
	StripeKey                 string
	StripeSecret              string
	WepayKey                  string
	WepaySecret               string
	PaypalKey                 string
	PaypalSecret              string
	SteamKey                  string
	HerokuKey                 string
	HerokuSecret              string
	UberKey                   string
	UberSecret                string
	SoundcloudKey             string
	SoundcloudSecret          string
	GitlabKey                 string
	GitlabSecret              string
	DailymotionKey            string
	DailymotionSecret         string
	DeezerKey                 string
	DeezerSecret              string
	DiscordKey                string
	DiscordSecret             string
	MeetupKey                 string
	MeetupSecret              string
	Auth0Key                  string
	Auth0Secret               string
	Auth0Domain               string
	XeroKey                   string
	XeroSecret                string
	VkKey                     string
	VkSecret                  string
	NaverKey                  string
	NaverSecret               string
	YandexKey                 string
	YandexSecret              string
	NextcloudKey              string
	NextcloudSecret           string
	NextcloudURL              string
	GiteaKey                  string
	GiteaSecret               string
	ShopifyKey                string
	ShopifySecret             string
	AppleKey                  string
	AppleSecret               string
	StravaKey                 string
	StravaSecret              string
	OpenidConnectKey          string
	OpenidConnectSecret       string
	OpenidConnectDiscoveryURL string
	DB                        Database `toml:"Database"`
}

Config : configurations settings

type Database

type Database struct {
	Host     string
	Port     string
	User     string
	Password string
	DbName   string
}

Database : dabatase connection infos

type User

type User struct {
	gorm.Model
	Provider          string
	Email             string `gorm:"type:varchar(100);unique_index"`
	Name              string
	FirstName         string
	LastName          string
	NickName          string
	Description       string
	UserID            string
	AvatarURL         string
	Location          string
	AccessToken       string
	AccessTokenSecret string
	RefreshToken      string
	ExpiresAt         time.Time
	IDToken           string
}

User : user info to database

func (*User) DeleteUserByID

func (user *User) DeleteUserByID(db *gorm.DB, uid uint32) (int64, error)

DeleteUserByID : find the user by id and delete it

func (*User) FindAllUsers

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

FindAllUsers : find the user by id and delete it

func (*User) FindUserByEMail

func (user *User) FindUserByEMail(db *gorm.DB, email string) (*User, error)

FindUserByEMail : find the user by email

func (*User) FindUserByID

func (user *User) FindUserByID(db *gorm.DB, uid uint32) (*User, error)

FindUserByID : find the user by id

func (*User) FromGothUser

func (user *User) FromGothUser(gothuser goth.User) error

FromGothUser : trasforming from goth user to this model

func (*User) SaveUser

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

SaveUser : create a new user

func (*User) UpdateUser

func (user *User) UpdateUser(db *gorm.DB, uid uint32) (*User, error)

UpdateUser : update user infos

Jump to

Keyboard shortcuts

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