account

package
v0.0.0-...-2feadb7 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2017 License: MIT Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NoVotesLeft                      error = errors.New("No votes left in bank!")
	InvalidUsernameOrPassword        error = errors.New("Invalid Username/Password")
	AccountNotYetVerified            error = errors.New("Account not yet verified.")
	AccountNicknameTooLong           error = errors.New("Your nickname cannot be longer than 15 characters!")
	AccountDoesNotNeedVerification   error = errors.New("Account doesn't need verifying!")
	AccountVerificationCodeNotMatch  error = errors.New("Bad verification code!")
	AccountPasswordResetNotRequested error = errors.New("Password reset not requested!")
	EmailAddressAlreadyInUse         error = errors.New("This email address is already in use!")
	PasswordNotAcceptable            error = errors.New("Password must contain at least 3 of types of characters from uppercase, lowercase, punctuation, and digits, and be at least 8 characters long.")
)

Functions

func CanAccountBeMade

func CanAccountBeMade(as AccountStorer, a *Account, passwordClearText string) error

func CheckAndCreateAccount

func CheckAndCreateAccount(as AccountStorer, email string, password string, nickname string) error

func DoPasswordResetRequestIfPossible

func DoPasswordResetRequestIfPossible(as AccountStorer, email string) error

func GenerateValidationKey

func GenerateValidationKey() (nullables.NullString, error)

func IsEmailInUse

func IsEmailInUse(as AccountStorer, email string) (bool, error)

func IsPasswordAcceptable

func IsPasswordAcceptable(plaintextPassword string) bool

Types

type Account

type Account struct {
	Id                            int64
	Email                         string               `sql:"unique; type:varchar(60);" validate:"nonzero"`
	Nickname                      string               `sql:"type:varchar(15); validate:"nonzero"`
	Password                      string               `sql:"type:varchar(60);"`
	VerificationCode              nullables.NullString `sql:"type:varchar(32)"`
	ResetPasswordVerificationCode nullables.NullString `sql:"type:varchar(32)"`
	CurrentSession                nullables.NullString `sql:"type:varchar(32)"`
	SessionExpires                nullables.NullTime
	VoteBank                      int64
	Admin                         bool
	CreatedAt                     nullables.NullTime
	UpdatedAt                     nullables.NullTime
	DeletedAt                     nullables.NullTime
}

func AttemptLogin

func AttemptLogin(as AccountStorer, propEmail string, propPassword string, willExpire bool) (*Account, error)

func (*Account) ApplyPasswordResetVerificationCode

func (a *Account) ApplyPasswordResetVerificationCode(as AccountStorer, resetVerificationCode string, newPassword string) error

func (*Account) ApplyVerificationCode

func (a *Account) ApplyVerificationCode(as AccountStorer, verificationCode string) error

func (*Account) AwaitingPasswordReset

func (a *Account) AwaitingPasswordReset() bool

func (*Account) ExpireSession

func (a *Account) ExpireSession(as AccountStorer) error

func (*Account) SetPassword

func (a *Account) SetPassword(cleartext string) error

func (*Account) UpdateVoteBank

func (a *Account) UpdateVoteBank(as AccountStorer, up bool, currentAccountVote int64) error

func (Account) Valid

func (a Account) Valid() error

type AccountStorer

type AccountStorer interface {
	LoadAccountFromEmail(email string) (*Account, error)
	LoadAccountFromId(int64) (*Account, error)
	LoadAccountFromSession(sessionId string) (*Account, error)
	CreateAccount(*Account) error
	SaveAccount(*Account) error
}

Jump to

Keyboard shortcuts

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