Documentation ¶
Index ¶
- Constants
- Variables
- func CheckExistingUserProvider(provider oauth.ProviderEnum, id string, userID int) (used bool, err error)
- func Close()
- func CountUsers() (count int, err error)
- func DeleteUserProvider(providerEnum oauth.ProviderEnum, userID int) (err error)
- func GetAllConfigs() (configsMap map[string]Config, err error)
- func GetConsumer(tag string) (err error)
- func GetDonationCountByUser(userID int) (count int, err error)
- func GetMySQLClient() (conn *gorm.DB, err error)
- func GetUserSteamID(userID int) int64
- func GetUserVerification(code string) (userID int, err error)
- func SendUserVerification(userID int, userEmail string, r *http.Request) error
- func SetChatBotSettings(discordID string, callback func(s *ChatBotSetting)) (err error)
- func SetConfig(id ConfigID, value string) (err error)
- func UpdateUserProvider(userID int, provider oauth.ProviderEnum, resp oauth.User) error
- func VerifyUser(userID int) error
- type ChatBotSetting
- type Config
- type ConfigID
- type Consumer
- type Donation
- type DonationSource
- type GroupedDonation
- type ProductKey
- type User
- func GetUserByAPIKey(key string) (user User, err error)
- func GetUserByEmail(email string) (user User, err error)
- func GetUserByID(id int) (user User, err error)
- func GetUserByProviderID(provider oauth.ProviderEnum, providerID string) (user User, err error)
- func NewUser(r *http.Request, userEmail, password string, prodCC steamapi.ProductCC, ...) (user User, err error)
- type UserLevel
- type UserProvider
- type UserVerification
Constants ¶
View Source
const ( DonationSourcePatreon = "patreon" DonationSourceManual = "manual" )
View Source
const ( ProductKeyTypeApp = "app" ProductKeyTypePackage = "package" ProductKeyFieldCommon = "common" ProductKeyFieldExtended = "extended" ProductKeyFieldUFS = "ufs" ProductKeyFieldConfig = "config" )
View Source
const ( UserLevelGuest UserLevel = iota // Guest UserLevelFree // Free UserLevel1 // Level 1 UserLevel2 // Level 2 UserLevel3 // Level 3 // Pages UserLevelLimitGuest = 5 // Guest UserLevelLimitFree = 10 // Free UserLevelLimit1 = 10 // Level 1 UserLevelLimit2 = 100 // Level 2 UserLevelLimit3 = 0 // Level 3 )
View Source
const (
ConsumerSessionLength = time.Second * 70 // Time to keep the key for
)
Variables ¶
View Source
var ErrExpiredVerification = errors.New("verification code expired")
View Source
var (
ErrRecordNotFound = gorm.ErrRecordNotFound
)
Functions ¶
func CountUsers ¶
func DeleteUserProvider ¶
func DeleteUserProvider(providerEnum oauth.ProviderEnum, userID int) (err error)
func GetAllConfigs ¶
func GetConsumer ¶
func GetDonationCountByUser ¶
func GetMySQLClient ¶
func GetUserSteamID ¶
func GetUserVerification ¶
func SendUserVerification ¶
func SetChatBotSettings ¶
func SetChatBotSettings(discordID string, callback func(s *ChatBotSetting)) (err error)
func UpdateUserProvider ¶
func VerifyUser ¶
Types ¶
type ChatBotSetting ¶
type ChatBotSetting struct { CreatedAt time.Time `gorm:"not null"` UpdatedAt time.Time `gorm:"not null"` DeletedAt *time.Time `gorm:""` DiscordID string `gorm:"not null;column:discord_id;primary_key"` ProductCode steamapi.ProductCC `gorm:"not null;column:product_cc;index:name"` }
func GetChatBotSettings ¶
func GetChatBotSettings(discordID string) (settings ChatBotSetting, err error)
type Config ¶
type Consumer ¶
type Consumer struct { Key string `gorm:"not null;column:key;primary_key"` Use bool `gorm:"not null;column:use;"` Expires time.Time `gorm:"not null;column:expires;type:datetime"` Owner string `gorm:"not null;column:owner"` IP string `gorm:"not null;column:ip"` Environment string `gorm:"not null;column:environment"` Version string `gorm:"not null;column:version"` Commits string `gorm:"not null;column:commits"` Notes string `gorm:"-"` }
type Donation ¶
type Donation struct { ID int `gorm:"not null;column:id;primary_key;auto_increment"` CreatedAt time.Time `gorm:"not null;column:created_at"` UserID int `gorm:"not null;column:user_id"` PlayerID int64 `gorm:"not null;column:player_id"` Email string `gorm:"not null;column:email"` AmountUSD int `gorm:"not null;column:amount_usd"` OriginalCurrency string `gorm:"not null;column:original_currency"` OriginalAmount int `gorm:"not null;column:original_amount"` Source string `gorm:"not null;column:source"` Anon bool `gorm:"not null;column:anon"` PatreonRef string `gorm:"column:patreon_ref"` // Nullable, indexed }
func GetDonationsByUser ¶
func LatestDonations ¶
type DonationSource ¶
type DonationSource string
type GroupedDonation ¶
func TopDonators ¶
func TopDonators() (donations []GroupedDonation, err error)
func (GroupedDonation) Format ¶
func (d GroupedDonation) Format() string
type ProductKey ¶
type ProductKey struct { Type string `gorm:"not null;primary_key"` Field string `gorm:"not null;primary_key"` Key string `gorm:"not null;primary_key"` CreatedAt time.Time `gorm:"not null"` UpdatedAt time.Time `gorm:"not null"` DeletedAt *time.Time `gorm:""` Count int `gorm:"not null"` }
func GetProductKeys ¶
func GetProductKeys() (keys []ProductKey, err error)
func (ProductKey) FieldTitle ¶
func (key ProductKey) FieldTitle() string
func (ProductKey) Save ¶
func (key ProductKey) Save() error
type User ¶
type User struct { ID int `gorm:"not null;column:id;primary_key"` CreatedAt time.Time `gorm:"not null;column:created_at"` UpdatedAt time.Time `gorm:"not null;column:updated_at"` LoggedInAt *time.Time `gorm:"column:logged_in_at;type:datetime"` Email string `gorm:"not null;column:email;unique_index"` EmailVerified bool `gorm:"not null;column:email_verified"` Password string `gorm:"not null;column:password"` Level UserLevel `gorm:"not null;column:level"` ProductCC steamapi.ProductCC `gorm:"not null;column:country_code"` APIKey string `gorm:"not null;column:api_key"` DonatedPatreon int `gorm:"not null;column:donated_patreon"` }
func GetUserByAPIKey ¶
func GetUserByEmail ¶
func GetUserByID ¶
func GetUserByProviderID ¶
func GetUserByProviderID(provider oauth.ProviderEnum, providerID string) (user User, err error)
func (User) SetPassword ¶
func (User) TouchLoggedInTime ¶
type UserProvider ¶
type UserProvider struct { UserID int `gorm:"not null;column:user_id;primary_key"` Provider oauth.ProviderEnum `gorm:"not null;column:provider;primary_key"` CreatedAt time.Time `gorm:"not null;column:created_at"` UpdatedAt time.Time `gorm:"not null;column:updated_at"` DeletedAt *time.Time `gorm:"not null;column:deleted_at"` Token string `gorm:"not null;column:token"` ID string `gorm:"not null;column:id"` Email string `gorm:"not null;column:email"` Username string `gorm:"not null;column:username"` Avatar string `gorm:"not null;column:avatar"` }
func GetUserProviderByProviderID ¶
func GetUserProviderByProviderID(provider oauth.ProviderEnum, providerID string) (userProvider UserProvider, err error)
func GetUserProviderByUserID ¶
func GetUserProviderByUserID(enum oauth.ProviderEnum, userID int) (userProvider UserProvider, err error)
func GetUserProviders ¶
func GetUserProviders(userID int) (providers []UserProvider, err error)
type UserVerification ¶
type UserVerification struct { CreatedAt time.Time `gorm:"not null;column:created_at"` Code string `gorm:"not null;column:code;primary_key"` UserID int `gorm:"not null;column:user_id"` Expires time.Time `gorm:"not null;column:expires"` }
func CreateUserVerification ¶
func CreateUserVerification(userID int) (userVerification UserVerification, err error)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.