Documentation ¶
Index ¶
- Constants
- func EmailSplit(email string) (string, string)
- func UpdateLastLogin(ctx context.Context, user gobwebs.User) error
- type BaseUser
- func (u *BaseUser) ComparePassword(password string) (bool, error)
- func (u *BaseUser) GetEmail() string
- func (u *BaseUser) GetID() uint
- func (u *BaseUser) IsAuthenticated() bool
- func (u *BaseUser) IsStaff() bool
- func (u *BaseUser) IsSuperUser() bool
- func (u *BaseUser) IsVerified() bool
- func (u *BaseUser) SetAuthenticated(flag bool)
- func (u *BaseUser) SetPassword(password string) error
- func (u *BaseUser) SetStaff(flag bool)
- func (u *BaseUser) SetSuperUser(flag bool)
- func (u *BaseUser) SetVerified(flag bool)
- type BlacklistValidator
- func (b *BlacklistValidator) EmailSafe(email string) bool
- func (b *BlacklistValidator) EmailSafeOnly(listing []string, email string) bool
- func (b *BlacklistValidator) EmailSafePlus(listing []string, email string) bool
- func (b *BlacklistValidator) UsernameSafe(username string) bool
- func (b *BlacklistValidator) UsernameSafeOnly(listing []string, email string) bool
- func (b *BlacklistValidator) UsernameSafePlus(listing []string, email string) bool
- type ChangePasswordForm
- type Confirmation
- type LoginEmailForm
- type LoginForm
- type ResetPasswordForm
- type Service
- func (s *Service) ChangePassword(c echo.Context) error
- func (s *Service) ChangePasswordPOST(c echo.Context) error
- func (s *Service) ConfirmEmailConf(c echo.Context) error
- func (s *Service) ForgotPassword(c echo.Context) error
- func (s *Service) ForgotPasswordConf(c echo.Context) error
- func (s *Service) ForgotPasswordConfPOST(c echo.Context) error
- func (s *Service) ForgotPasswordPOST(c echo.Context) error
- func (s *Service) Login(c echo.Context) error
- func (s *Service) LoginAuth(c echo.Context) error
- func (s *Service) LoginAuthPOST(c echo.Context) error
- func (s *Service) LoginEmail(c echo.Context) error
- func (s *Service) LoginEmailConf(c echo.Context) error
- func (s *Service) LoginEmailPOST(c echo.Context) error
- func (s *Service) LoginPOST(c echo.Context) error
- func (s *Service) Logout(c echo.Context) error
- func (s *Service) RegisterRoutes()
- func (s *Service) RouteName(value string) string
- func (s *Service) UpdateEmail(c echo.Context) error
- func (s *Service) UpdateEmailConf(c echo.Context) error
- func (s *Service) UpdateEmailPOST(c echo.Context) error
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func EmailSplit ¶
EmailSplit will return the username and domain parts of an email address
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 ¶
ComparePassword ..
func (*BaseUser) GetEmail ¶
GetEmail returns the user email address
func (*BaseUser) IsAuthenticated ¶
IsAuthenticated returns if the user is authenticated
func (*BaseUser) IsStaff ¶
IsStaff returns if the user is a staff user
func (*BaseUser) IsSuperUser ¶
IsSuperUser returns if the user is a super user
func (*BaseUser) IsVerified ¶
IsVerified returns whether or not the user has confirmed their email address
func (*BaseUser) SetAuthenticated ¶
SetAuthenticated sets the superuser status for user object
func (*BaseUser) SetPassword ¶
SetPassword ...
func (*BaseUser) SetStaff ¶
SetStaff sets the superuser status for user object
func (*BaseUser) SetSuperUser ¶
SetSuperUser 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 ¶
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 ...
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 ¶
NewService return service
func (*Service) ChangePassword ¶
ChangePassword changes the password for an authenticated user
func (*Service) ChangePasswordPOST ¶
ChangePasswordPOST changes the password for an authenticated user
func (*Service) ConfirmEmailConf ¶
ConfirmEmailConf confirms a users email and marks them as verified
func (*Service) ForgotPassword ¶
ForgotPassword ...
func (*Service) ForgotPasswordConf ¶
ForgotPasswordConf logs a user in via confirmation link
func (*Service) ForgotPasswordConfPOST ¶
ForgotPasswordConfPOST changes the password for an authenticated user
func (*Service) ForgotPasswordPOST ¶
ForgotPasswordPOST ...
func (*Service) LoginAuthPOST ¶
LoginAuthPOST ...
func (*Service) LoginEmailConf ¶
LoginEmailConf logs a user in via confirmation link
func (*Service) LoginEmailPOST ¶
LoginEmailPOST ...
func (*Service) UpdateEmail ¶
UpdateEmail changes the password for an authenticated user
func (*Service) UpdateEmailConf ¶
UpdateEmailConf ...