accounts

package
v0.0.0-...-4ee5816 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2023 License: BSD-3-Clause Imports: 18 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// EMAILCONF Email conf
	EMAILCONF int = iota + 1
	// EMAILCHCONF Email change conf
	EMAILCHCONF
	// PASSWDRESETCONF Password reset conf
	PASSWDRESETCONF
	// LOGINEMAIL is an email login conf
	LOGINEMAIL
)

Variables

This section is empty.

Functions

func EmailSplit

func EmailSplit(email string) (string, string)

EmailSplit will return the username and domain parts of an email address

func UpdateLastLogin

func UpdateLastLogin(ctx context.Context, user gobwebs.User) error

UpdateLastLogin updates the last login time for a user

Types

type BaseUser

type BaseUser struct {
	ID       uint   `db:"id" validate:"-"`
	Email    string `db:"email"`
	Password string `db:"password"`

	CreatedOn time.Time    `db:"created_on"`
	LastLogin sql.NullTime `db:"last_login"`
	// contains filtered or unexported fields
}

BaseUser is a base user object. Other structs should embed this

func (*BaseUser) ComparePassword

func (u *BaseUser) ComparePassword(password string) (bool, error)

ComparePassword ..

func (*BaseUser) GetEmail

func (u *BaseUser) GetEmail() string

GetEmail returns the user email address

func (*BaseUser) GetID

func (u *BaseUser) GetID() uint

GetID returns the user ID

func (*BaseUser) IsAuthenticated

func (u *BaseUser) IsAuthenticated() bool

IsAuthenticated returns if the user is authenticated

func (*BaseUser) IsStaff

func (u *BaseUser) IsStaff() bool

IsStaff returns if the user is a staff user

func (*BaseUser) IsSuperUser

func (u *BaseUser) IsSuperUser() bool

IsSuperUser returns if the user is a super user

func (*BaseUser) IsVerified

func (u *BaseUser) IsVerified() bool

IsVerified returns whether or not the user has confirmed their email address

func (*BaseUser) SetAuthenticated

func (u *BaseUser) SetAuthenticated(flag bool)

SetAuthenticated sets the superuser status for user object

func (*BaseUser) SetPassword

func (u *BaseUser) SetPassword(password string) error

SetPassword ...

func (*BaseUser) SetStaff

func (u *BaseUser) SetStaff(flag bool)

SetStaff sets the superuser status for user object

func (*BaseUser) SetSuperUser

func (u *BaseUser) SetSuperUser(flag bool)

SetSuperUser sets the superuser status for user object

func (*BaseUser) SetVerified

func (u *BaseUser) SetVerified(flag bool)

SetVerified sets the superuser status for user object

type BlacklistValidator

type BlacklistValidator struct{}

BlacklistValidator is a checker to validate input against blacklists

func (*BlacklistValidator) EmailSafe

func (b *BlacklistValidator) EmailSafe(email string) bool

EmailSafe will verify an email domain is not in the default blacklist

func (*BlacklistValidator) EmailSafeOnly

func (b *BlacklistValidator) EmailSafeOnly(listing []string, email string) bool

EmailSafeOnly will only check the given email domain against the provided list. This will exclude the default `emailBlacklist`

func (*BlacklistValidator) EmailSafePlus

func (b *BlacklistValidator) EmailSafePlus(listing []string, email string) bool

EmailSafePlus will concatenate given list to default `emailBlacklist` and check the given email to see if the domain is in either list.

func (*BlacklistValidator) UsernameSafe

func (b *BlacklistValidator) UsernameSafe(username string) bool

UsernameSafe will verify a username is not in the default blacklist

func (*BlacklistValidator) UsernameSafeOnly

func (b *BlacklistValidator) UsernameSafeOnly(listing []string, email string) bool

UsernameSafeOnly will only check the given email domain against the provided list. This will exclude the default `emailBlacklist`

func (*BlacklistValidator) UsernameSafePlus

func (b *BlacklistValidator) UsernameSafePlus(listing []string, email string) bool

UsernameSafePlus will concatenate given list to default `usernameBlacklist` and check the given email to see if the domain is in either list.

type ChangePasswordForm

type ChangePasswordForm struct {
	CPassword  string `form:"current_password" validate:"required,max=100"`
	NPassword  string `form:"new_password" validate:"required,max=100"`
	NPassword2 string `form:"new_password2" validate:"required,max=100"`
}

ChangePasswordForm ...

func (*ChangePasswordForm) Validate

func (ch *ChangePasswordForm) Validate(c echo.Context) error

Validate should valide user input

type Confirmation

type Confirmation struct {
	ID                 uint           `db:"id"`
	Type               int            `db:"type"`
	ConfirmationTarget sql.NullString `db:"confirmation_target"`
	UserID             uint           `db:"user_id"`
	Key                string         `db:"key"`
	ConfirmTime        sql.NullTime   `db:"confirm_time"`
	ExpireTime         time.Time      `db:"expire_time"`
	CreatedOn          time.Time      `db:"created_on"`
	UpdatedOn          time.Time      `db:"updated_on"`
}

Confirmation is a struct to hold confirmation requests

func GetConfirmation

func GetConfirmation(ctx context.Context, key string) (*Confirmation, error)

GetConfirmation will fetch from the db using the given key

func NewConfirmation

func NewConfirmation(ctype int, user gobwebs.User, expires time.Time) *Confirmation

NewConfirmation creates a new confirmation object

func (*Confirmation) Confirm

func (c *Confirmation) Confirm(ctx context.Context) error

Confirm sets `confirm_time`, essentially confirming the confimration request

func (*Confirmation) IsValid

func (c *Confirmation) IsValid(ctype int) bool

IsValid simple validation ensuring the expire time hasn't passed

func (*Confirmation) Load

func (c *Confirmation) Load(ctx context.Context) error

Load will load a confirmation using the Key value

func (*Confirmation) Store

func (c *Confirmation) Store(ctx context.Context) error

Store saves a new confirmation to the database.

type LoginEmailForm

type LoginEmailForm struct {
	Email string `form:"email" validate:"required,email,max=255"`
}

LoginEmailForm ...

func (*LoginEmailForm) Validate

func (l *LoginEmailForm) Validate(c echo.Context) error

Validate should be used to validate user input

type LoginForm

type LoginForm struct {
	Email    string `form:"email" validate:"required,email,max=255"`
	Password string `form:"password" validate:"required,max=100"`
	Next     string `form:"next" validate:"-"`
	// contains filtered or unexported fields
}

LoginForm ...

func (*LoginForm) Validate

func (l *LoginForm) Validate(c echo.Context, fetch gobwebs.UserFetch) error

Validate should be used to validate user input

type ResetPasswordForm

type ResetPasswordForm struct {
	NPassword  string `form:"new_password" validate:"required,max=100"`
	NPassword2 string `form:"new_password2" validate:"required,max=100"`
}

ResetPasswordForm ...

func (*ResetPasswordForm) Validate

func (ch *ResetPasswordForm) Validate(c echo.Context) error

Validate should valide user input

type Service

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

Service is the base accounts service struct

func NewService

func NewService(eg *echo.Group, name string, fetch gobwebs.UserFetch) *Service

NewService return service

func (*Service) ChangePassword

func (s *Service) ChangePassword(c echo.Context) error

ChangePassword changes the password for an authenticated user

func (*Service) ChangePasswordPOST

func (s *Service) ChangePasswordPOST(c echo.Context) error

ChangePasswordPOST changes the password for an authenticated user

func (*Service) ConfirmEmailConf

func (s *Service) ConfirmEmailConf(c echo.Context) error

ConfirmEmailConf confirms a users email and marks them as verified

func (*Service) ForgotPassword

func (s *Service) ForgotPassword(c echo.Context) error

ForgotPassword ...

func (*Service) ForgotPasswordConf

func (s *Service) ForgotPasswordConf(c echo.Context) error

ForgotPasswordConf logs a user in via confirmation link

func (*Service) ForgotPasswordConfPOST

func (s *Service) ForgotPasswordConfPOST(c echo.Context) error

ForgotPasswordConfPOST changes the password for an authenticated user

func (*Service) ForgotPasswordPOST

func (s *Service) ForgotPasswordPOST(c echo.Context) error

ForgotPasswordPOST ...

func (*Service) Login

func (s *Service) Login(c echo.Context) error

Login ..

func (*Service) LoginAuth

func (s *Service) LoginAuth(c echo.Context) error

LoginAuth ...

func (*Service) LoginAuthPOST

func (s *Service) LoginAuthPOST(c echo.Context) error

LoginAuthPOST ...

func (*Service) LoginEmail

func (s *Service) LoginEmail(c echo.Context) error

LoginEmail ...

func (*Service) LoginEmailConf

func (s *Service) LoginEmailConf(c echo.Context) error

LoginEmailConf logs a user in via confirmation link

func (*Service) LoginEmailPOST

func (s *Service) LoginEmailPOST(c echo.Context) error

LoginEmailPOST ...

func (*Service) LoginPOST

func (s *Service) LoginPOST(c echo.Context) error

LoginPOST ...

func (*Service) Logout

func (s *Service) Logout(c echo.Context) error

Logout ...

func (*Service) RegisterRoutes

func (s *Service) RegisterRoutes()

RegisterRoutes ...

func (*Service) RouteName

func (s *Service) RouteName(value string) string

RouteName ...

func (*Service) UpdateEmail

func (s *Service) UpdateEmail(c echo.Context) error

UpdateEmail changes the password for an authenticated user

func (*Service) UpdateEmailConf

func (s *Service) UpdateEmailConf(c echo.Context) error

UpdateEmailConf ...

func (*Service) UpdateEmailPOST

func (s *Service) UpdateEmailPOST(c echo.Context) error

UpdateEmailPOST changes the password for an authenticated user

Jump to

Keyboard shortcuts

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