auth

package
v0.0.0-...-8a04328 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2018 License: GPL-3.0, GPL-3.0-only Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ACCOUNT_STATUS_CREATED is the default value for any created account
	ACCOUNT_STATUS_CREATED = "CREATED"

	// ACCOUNT_STATUS_MAIL_SEND is the value for any account the activation mail is sent for
	ACCOUNT_STATUS_MAIL_SEND = "MAIL_SEND"

	// ACCOUNT_STATUS_VERIFIED is for every account that has a verified email
	ACCOUNT_STATUS_EMAIL_VERIFIED = "EMAIL_VERIFIED"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type JsonUser

type JsonUser User

type User

type User struct {
	schema.DatabaseObject
	ActiveAt            time.Time `json:"-"`
	Username            string    `gorm:"size:128;unique" json:"username"`
	Email               string    `gorm:"size:128;unique" json:"email"`
	Password            string    `gorm:"size:64" json:"-"`
	QuotaSongs          int64     `json:"quota_songs"`
	QuotaSpace          int64     `json:"quota_space"`
	EmailActivationCode string    `gorm:"size:40" json:"-"`
	AccountStatus       string    `gorm:"size:256" json:"-"`
	AuthProvider        string    `json:"auth_provider"`
	DisplayName         string    `gorm:"size:1024" json:"display_name"`
}

func (User) CheckPassword

func (u User) CheckPassword(password string) bool

func (*User) GetAvailableQuota

func (u *User) GetAvailableQuota() (int64, int64)

GetAvailableQuota returns the available quota for a given user. First, it returns available space (in bytes) second, it returns the number of songs the user is allowed to upload until his quota is reached

func (User) MarshalJSON

func (u User) MarshalJSON() ([]byte, error)

func (User) QueueSendActivationMail

func (u User) QueueSendActivationMail()

type UserSession

type UserSession struct {
	schema.DatabaseObject
	UserID     string `gorm:"size:64"`
	User       User
	Secret     string `gorm:"size:128"`
	UserAgent  string `gorm:"size:1024"`
	ValidUntil time.Time
}

UserSession maps a user to a secret to allow him to stay signed in across multiple sessions

func NewUserSessionForUser

func NewUserSessionForUser(user User) UserSession

NewUserSessionForUser returns a new user session for the given user

Jump to

Keyboard shortcuts

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