auth

package
v0.0.0-...-b2d0f57 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VerifyEmailTokenExpr       = time.Minute * 5     // 5 minutes
	ResetPasswordTokenExpr     = time.Minute * 10    // 10 minutes
	AccessTokenExpr            = time.Minute * 30    // 30 minutes
	RefreshTokenExpr           = time.Hour * 24 * 14 // 2 weeks
	LockAccountDuration        = time.Second * 5
	MaximumFailedLoginAttempts = 5
)

Variables

View Source
var (
	ErrInvalidValidation = errors.New("invalid validation")
	ErrAccessDenied      = errors.New("access denied")
	ErrEmailNotVerified  = errors.New("email not verified")
	ErrAccountLocked     = errors.New("account locked")
)

General errors

View Source
var (
	ErrNotFound               = errors.New("user not found")
	ErrInvalidEmailOrPassword = errors.New("invalid email or password")
	ErrEmailAlreadyExist      = errors.New("email already exists")
	ErrUsernameAlreadyExist   = errors.New("username already exists")
)

User errors

View Source
var (
	ErrGenerateToken    = errors.New("failed to generate token")
	ErrHashingPassword  = errors.New("failed to hash password")
	ErrCreateAuthStore  = errors.New("failed to create auth store")
	ErrCreateUser       = errors.New("failed to create user")
	ErrCreateEmailToken = errors.New("failed to create email token")
	ErrDestroyToken     = errors.New("failed to destroy token")
	ErrVerifyEmail      = errors.New("failed to verify email")
)

Authentication errors

View Source
var (
	ErrChangePassword           = errors.New("failed to change password")
	ErrClearFailedLoginAttempts = errors.New("failed to clear failed login attempts")
)

Password management errors

View Source
var (
	ErrUnlockAccount   = errors.New("failed to unlock account")
	ErrLockAccount     = errors.New("failed to lock account")
	ErrDeleteUser      = errors.New("failed to delete user")
	ErrEmailWasNotSent = errors.New("email was not sent")
)

Account management errors

Functions

This section is empty.

Types

type AuthService

type AuthService struct {
	AuthService auth_manager.AuthManager
	// contains filtered or unexported fields
}

func NewAuthService

func NewAuthService(authRepo repository.AuthRepository, userRepo repository.UserRepository, authManager auth_manager.AuthManager, hashManager *hash.HashManager, emailService email.EmailService) *AuthService

func (*AuthService) Authenticate

func (a *AuthService) Authenticate(ctx context.Context, accessToken string) (*model.User, *vali.Varror)

func (*AuthService) ChangePassword

func (a *AuthService) ChangePassword(ctx context.Context, userID model.UserID, oldPassword string, newPassword string) *vali.Varror

func (*AuthService) DeleteAccount

func (s *AuthService) DeleteAccount(ctx context.Context, userID model.UserID, password string) *vali.Varror

func (*AuthService) Login

func (a *AuthService) Login(ctx context.Context, email string, password string) (_ *model.User, act string, rft string, varror *vali.Varror)

func (*AuthService) RefreshToken

func (a *AuthService) RefreshToken(ctx context.Context, userID model.UserID, refreshToken string) (string, *vali.Varror)

func (*AuthService) Register

func (a *AuthService) Register(ctx context.Context, name string, lastName string, username string, email string, password string, verifyEmailRedirectUrl string) (verifyEmailToken string, varror *vali.Varror)

func (*AuthService) SendResetPassword

func (a *AuthService) SendResetPassword(ctx context.Context, email string, resetPasswordRedirectUrl string) (token string, timeout time.Duration, varror *vali.Varror)

func (*AuthService) SubmitResetPassword

func (a *AuthService) SubmitResetPassword(ctx context.Context, token string, newPassword string) *vali.Varror

func (*AuthService) VerifyEmail

func (a *AuthService) VerifyEmail(ctx context.Context, verifyEmailToken string) *vali.Varror

type DetailedValidation

type DetailedValidation struct {
	Detail []string
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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