services

package
v0.0.0-...-b623679 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountsService

type AccountsService struct {
	DB *sql.DB
}

func (*AccountsService) CleanPendingEmail

func (service *AccountsService) CleanPendingEmail(id int) error

func (*AccountsService) CreateAccount

func (service *AccountsService) CreateAccount(account *types.Account) error

Creates an account in the database

func (*AccountsService) DeleteAccount

func (service *AccountsService) DeleteAccount(id int) error

Deletes an account in the database

func (*AccountsService) DisableTOTP

func (service *AccountsService) DisableTOTP(id int) error

Disables 2fa totp for an account

func (*AccountsService) EnableTOTP

func (service *AccountsService) EnableTOTP(id int) error

Enables 2fa totp for an account

func (*AccountsService) GetAccountByEmail

func (service *AccountsService) GetAccountByEmail(email string) (*types.Account, error)

Gets an account by email

func (*AccountsService) GetAccountByID

func (service *AccountsService) GetAccountByID(id int) (*types.Account, error)

Gets an account by id

func (*AccountsService) MarkAccountAsVerified

func (service *AccountsService) MarkAccountAsVerified(id int) error

Marks the account as verified

func (*AccountsService) SavePending

func (service *AccountsService) SavePending(email string, account int) error

Saves pending email before confirmation

func (*AccountsService) UpdateAccountEmail

func (service *AccountsService) UpdateAccountEmail(email string, id int) error

Updates account email in the database

func (*AccountsService) UpdateAccountPassword

func (service *AccountsService) UpdateAccountPassword(password string, id int) error

Updates account password in the database

type BlacklistService

type BlacklistService struct {
	DB *sql.DB
}

func (*BlacklistService) FindToken

func (service *BlacklistService) FindToken(tokenID string) (bool, error)

Tries to find a blacklisted token

func (*BlacklistService) RevokeToken

func (service *BlacklistService) RevokeToken(tokenID string, id int, expiration time.Time) error

Revokes jwt tokens

type EmailService

type EmailService struct {
	FS embed.FS
	DB *sql.DB
}

func (*EmailService) AddRecoveryCode

func (service *EmailService) AddRecoveryCode(code string, account int) error

Adds the recovery code to the database

func (*EmailService) AddVerificationCode

func (service *EmailService) AddVerificationCode(code string, account int) error

Adds the verification code to the database

func (*EmailService) CompareCodes

func (service *EmailService) CompareCodes(code string, account int) error

Compares the stored and the inputted verification codes

func (*EmailService) CompareRecoveryCodes

func (service *EmailService) CompareRecoveryCodes(code string, account int) error

Compares the stored and the inputted recovery codes

func (*EmailService) DeleteCodes

func (service *EmailService) DeleteCodes(account int) error

Deletes the account codes

func (*EmailService) GetAccountIDByCodeOwnership

func (service *EmailService) GetAccountIDByCodeOwnership(code string) (int, error)

Gets an account by code ownership

func (*EmailService) SendEmail

func (service *EmailService) SendEmail(email, subject, path string, data interface{}) error

Sends emails based on template and data

func (*EmailService) SendNotificationEmail

func (service *EmailService) SendNotificationEmail(email, subject, message string) error

Sends a notification email

func (*EmailService) SendRecoveryEmail

func (service *EmailService) SendRecoveryEmail(email, code string) error

Sends an account recovery email

func (*EmailService) SendVerificationEmail

func (service *EmailService) SendVerificationEmail(email, code string) error

Sends a verification email

type TotpService

type TotpService struct {
	DB *sql.DB
}

func (*TotpService) AddBackupCodes

func (service *TotpService) AddBackupCodes(codes []string, account int) error

Stores backup codes in the database

func (*TotpService) DeleteBackupCodes

func (service *TotpService) DeleteBackupCodes(account int) error

Deletes backup codes

func (*TotpService) GenerateBackupCodes

func (service *TotpService) GenerateBackupCodes(count int, length int) ([]string, error)

Generates backup codes

func (*TotpService) GenerateQRCode

func (service *TotpService) GenerateQRCode(key *otp.Key) ([]byte, error)

Generates a qrcode

func (*TotpService) GenerateTOTPSecret

func (service *TotpService) GenerateTOTPSecret(email string, id int) (*otp.Key, error)

Generates and a saves a totp secret

func (*TotpService) ValidateBackupCode

func (service *TotpService) ValidateBackupCode(account int, code string) error

Validates backup codes

func (*TotpService) ValidateTOTP

func (service *TotpService) ValidateTOTP(id int, code string) (bool, error)

Validates a totp code

Jump to

Keyboard shortcuts

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