user

package
v0.0.0-...-e2fe045 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserNotFound         = errors.New("user not found")
	ErrUserAlreadyExists    = errors.New("user already exists")
	ErrUserEmailNotVerified = errors.New("email not verified")
	ErrPasswordIncorrect    = errors.New("incorrect password")
	ErrNotVerified          = errors.New("not verified")
)

Functions

func CheckVerified

func CheckVerified(ctx context.Context, db *database.DB, user *User) (context.Context, error)

func Delete

func Delete(ctx context.Context, db *database.DB, id int64) error

func GetCount

func GetCount(db *database.DB) (int, error)

func NewPasswordReset

func NewPasswordReset(db *database.DB, uid int64, secret string) error

func SettingsUpdatePasswordReset

func SettingsUpdatePasswordReset(currentPassword string, newPassword string, user *User, db *database.DB) error

func UpdatePasswordReset

func UpdatePasswordReset(data *models.NewPasswordFormData, db *database.DB) error

func VerifyEmail

func VerifyEmail(db *database.DB, uid int64, secret string) error

func VerifyPasswordReset

func VerifyPasswordReset(db *database.DB, uid string, secret string) error

Types

type User

type User struct {
	ID                  int64          `db:"user_id"`
	Email               string         `db:"email"`
	EmailVerified       sql.NullTime   `db:"email_verified"`
	EmailVerifySecret   string         `db:"email_verify_secret"`
	PasswordHash        string         `db:"password_hash"`
	PasswordResetSecret sql.NullString `db:"password_reset_secret"`
	PasswordResetExp    time.Time      `db:"password_reset_expires"`
	LastPasswordChange  time.Time      `db:"last_password_change"`
	Created             time.Time      `db:"created"`
	LastLogin           time.Time      `db:"last_login"`
	LastFailedAttempt   sql.NullTime   `db:"last_failed_attempt"`
	FailedAttemptCount  uint8          `db:"num_failed_attempts"`
	OtpSecret           sql.NullString `db:"otp_secret"`
	OtpRecovery         sql.NullString `db:"otp_recovery"`
	OtpAttempts         uint8          `db:"otp_recovery_attempts"`
	ProviderId          sql.NullInt64  `db:"provider_id"`
	Provider            *models.Provider
}

func Add

func Add(db *database.DB, cfg *config.Config, r *http.Request, taskDistributor worker.TaskDistributor, email string, password string) (*User, error)

func GetByEmail

func GetByEmail(db *database.DB, email string) (*User, error)

Jump to

Keyboard shortcuts

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