sessions

package
v0.0.0-...-589e68f Latest Latest
Warning

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

Go to latest
Published: May 21, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsUnique

func IsUnique(username string) (bool, error)

IsUnique returns true of the user has a unique username (one that is not yet in the database)

Types

type OAuth

type OAuth struct {
	UserID     uint32        `persistence:"primary;references:user(userid)" `
	Username   string        `json:"username"`
	AvatarURL  string        `json:"avatar"`
	Provider   string        `json:"provider" persistence:"primary"`
	ProviderID string        `json:"provider_id"`
	Token      *oauth2.Token `json:"-" persistence:"-"`
	Session    string        `json:"session,omitempty"`
}

type Sessions

type Sessions struct {
	// contains filtered or unexported fields
}

Sessions is the collection of receipts

func NewSessions

func NewSessions() *Sessions

IntializeDatabase creates or updates the session table and then creates the DAO

func (*Sessions) IsConnected

func (s *Sessions) IsConnected(user core.User) bool

IsConnected takes in a user to see if they are logged in

func (*Sessions) RemoveSession

func (s *Sessions) RemoveSession(sessionToken string) error

RemoveSession takes in a user and remove their session token

func (*Sessions) UpdateSession

func (s *Sessions) UpdateSession(user *User) error

UpdateSession takes in a user and updates their session token

type User

type User struct {
	// contains filtered or unexported fields
}

func GetAll

func GetAll(limit, offset int) ([]User, error)

func GetUserFromSession

func GetUserFromSession(session string) (*User, error)

func GetUserFromUserId

func GetUserFromUserId(id uint32) (*User, error)

func GetUserFromUsername

func GetUserFromUsername(username string) (*User, error)

func New

func New(userid uint32) *User

func NewAuthentication

func NewAuthentication(username string) *User

func NewRegistration

func NewRegistration(username, email string) *User

func (*User) Create

func (u *User) Create() error

func (*User) Created

func (u *User) Created() *time.Time

func (*User) Deleted

func (u *User) Deleted() *time.Time

func (*User) DoHashesMatch

func (u *User) DoHashesMatch(password string) (bool, error)

DoHashesMatch validates that a provided password hashes to the encrypted hash stored in the database

func (*User) Email

func (u *User) Email() string

func (*User) Hash

func (u *User) Hash() string

func (*User) OAuths

func (u *User) OAuths() []OAuth

func (*User) Save

func (u *User) Save() error

Update attempts to update an existing user in the database

func (*User) Secret

func (u *User) Secret() (string, error)

Secret attempts to fetch the secret for a user

func (*User) SessionToken

func (u *User) SessionToken() string

func (*User) SetEmail

func (u *User) SetEmail(email string)

func (*User) SetHash

func (u *User) SetHash(hash string)

func (*User) SetOAuths

func (u *User) SetOAuths(oauths []OAuth)

func (*User) SetSessionToken

func (u *User) SetSessionToken(sessionToken string)

func (*User) SetTotpSecret

func (u *User) SetTotpSecret(secret string)

func (*User) SetUsername

func (u *User) SetUsername(username string)

func (*User) TotpSecret

func (u *User) TotpSecret() string

func (*User) Updated

func (u *User) Updated() *time.Time

func (*User) UserId

func (u *User) UserId() uint32

func (*User) Username

func (u *User) Username() string

Jump to

Keyboard shortcuts

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