Versions in this module Expand all Collapse all v0 v0.16.0 Oct 21, 2026 Changes in this version + const MinPasswordLength + const OAuthAdminKey + const OAuthNextKey + const OAuthStateKey + const ProviderEmail + const ProviderGitHub + const ProviderPassword + var ErrAdminExists = errors.New("this site already has an admin") + var ErrLastAdmin = errors.New("cannot demote the last admin") + var ErrNoPasswordUser = errors.New("no matching password user") + var ErrNotConfiguredAdmin = errors.New("user is not the configured admin") + var ErrSetupCodeWrong = errors.New("that is not the setup code") + var ErrSetupRateLimited = errors.New("too many attempts; wait a few minutes and try again") + func CheckPassword(password string) error + func ClearSetupCode() + func NewOAuthState() (string, error) + func NewSetupCode() (string, error) + func SetupUnlocked(c *gin.Context) bool + func UnlockSetup(c *gin.Context, code string) error + type AccessTokenResponse struct + AccessToken string + type AdminUser struct + BlogUser BlogUser + BlogUserID int + type Auth struct + Mailer mail.Sender + func New(db *gorm.DB, version string) Auth + func (a *Auth) AdminExists() bool + func (a *Auth) CreatePasswordAdmin(email, password string) (*BlogUser, error) + func (a *Auth) CurrentUser(c *gin.Context) *BlogUser + func (a *Auth) DemoteAdmin(userID int) error + func (a *Auth) DisplayUserTable() + func (a *Auth) EmailLoginEnabled() bool + func (a *Auth) EnsureAdmin(user *BlogUser) error + func (a *Auth) GithubCallback(c *gin.Context) + func (a *Auth) IsAdmin(c *gin.Context) bool + func (a *Auth) IsLoggedIn(c *gin.Context) bool + func (a *Auth) IsWizardMode(c *gin.Context) bool + func (a *Auth) ListUsers(offset, limit int) ([]UserListing, int64, error) + func (a *Auth) PasswordLogin(c *gin.Context, next string) + func (a *Auth) PasswordLoginEnabled() bool + func (a *Auth) PromoteAdmin(userID int) error + func (a *Auth) RequestUser(accessToken string) (*BlogUser, error) + func (a *Auth) ResetPassword(email string) (string, string, error) + func (a *Auth) SendLoginCodeHandler(c *gin.Context) + func (a *Auth) StartSession(c *gin.Context, user *BlogUser) error + func (a *Auth) UpdateDb(db *gorm.DB) + func (a *Auth) UpsertUser(user *BlogUser) (*BlogUser, error) + func (a *Auth) VerifyLoginCodeHandler(c *gin.Context) + type BlogUser struct + AccessToken string + AvatarURL string + Email string + ID int + Login string + Name string + PasswordHash string + Provider string + ProviderID string + func (u BlogUser) DisplayName() string + type IAuth interface + CurrentUser func(c *gin.Context) *BlogUser + DemoteAdmin func(userID int) error + EmailLoginEnabled func() bool + IsAdmin func(c *gin.Context) bool + IsLoggedIn func(c *gin.Context) bool + IsWizardMode func(c *gin.Context) bool + ListUsers func(offset, limit int) ([]UserListing, int64, error) + PromoteAdmin func(userID int) error + type LoginCode struct + Attempts int + CodeHash string + CreatedAt time.Time + Email string + ExpiresAt time.Time + type UserListing struct + IsAdmin bool