services

package
v0.0.0-...-d30cded Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Accounts = &AccountService{
		ServiceUsingDB: ServiceUsingDB{
			container: datastore.Container,
		},
		ServiceUsingUuid: ServiceUsingUuid{
			container: uuid.Container,
		},
	}
)

Initialize a account service singleton instance

View Source
var (
	ForgetPasswords = &ForgetPasswordService{
		ServiceUsingConfig: ServiceUsingConfig{
			container: settings.Container,
		},
		ServiceUsingMailer: ServiceUsingMailer{
			container: mail.Container,
		},
	}
)

Initialize a forget password service singleton instance

View Source
var (
	Tokens = &TokenService{
		ServiceUsingDB: ServiceUsingDB{
			container: datastore.Container,
		},
		ServiceUsingConfig: ServiceUsingConfig{
			container: settings.Container,
		},
	}
)

Initialize a user token service singleton instance

View Source
var (
	TransactionCategories = &TransactionCategoryService{
		ServiceUsingDB: ServiceUsingDB{
			container: datastore.Container,
		},
		ServiceUsingUuid: ServiceUsingUuid{
			container: uuid.Container,
		},
	}
)

Initialize a transaction category service singleton instance

View Source
var (
	TransactionTags = &TransactionTagService{
		ServiceUsingDB: ServiceUsingDB{
			container: datastore.Container,
		},
		ServiceUsingUuid: ServiceUsingUuid{
			container: uuid.Container,
		},
	}
)

Initialize a transaction tag service singleton instance

View Source
var (
	Transactions = &TransactionService{
		ServiceUsingDB: ServiceUsingDB{
			container: datastore.Container,
		},
		ServiceUsingUuid: ServiceUsingUuid{
			container: uuid.Container,
		},
	}
)

Initialize a transaction service singleton instance

View Source
var (
	TwoFactorAuthorizations = &TwoFactorAuthorizationService{
		ServiceUsingDB: ServiceUsingDB{
			container: datastore.Container,
		},
		ServiceUsingConfig: ServiceUsingConfig{
			container: settings.Container,
		},
		ServiceUsingUuid: ServiceUsingUuid{
			container: uuid.Container,
		},
	}
)

Initialize a 2fa service singleton instance

View Source
var (
	Users = &UserService{
		ServiceUsingDB: ServiceUsingDB{
			container: datastore.Container,
		},
		ServiceUsingUuid: ServiceUsingUuid{
			container: uuid.Container,
		},
	}
)

Initialize a user service singleton instance

Functions

This section is empty.

Types

type AccountService

type AccountService struct {
	ServiceUsingDB
	ServiceUsingUuid
}

AccountService represents account service

func (*AccountService) CreateAccounts

func (s *AccountService) CreateAccounts(mainAccount *models.Account, childrenAccounts []*models.Account, utcOffset int16) error

CreateAccounts saves a new account model to database

func (*AccountService) DeleteAccount

func (s *AccountService) DeleteAccount(uid int64, accountId int64) error

DeleteAccount deletes an existed account from database

func (*AccountService) GetAccountAndSubAccountsByAccountId

func (s *AccountService) GetAccountAndSubAccountsByAccountId(uid int64, accountId int64) ([]*models.Account, error)

GetAccountAndSubAccountsByAccountId returns account model and sub account models according to account id

func (*AccountService) GetAccountMapByList

func (s *AccountService) GetAccountMapByList(accounts []*models.Account) map[int64]*models.Account

GetAccountMapByList returns an account map by a list

func (*AccountService) GetAccountsByAccountIds

func (s *AccountService) GetAccountsByAccountIds(uid int64, accountIds []int64) (map[int64]*models.Account, error)

GetAccountsByAccountIds returns account models according to account ids

func (*AccountService) GetAllAccountsByUid

func (s *AccountService) GetAllAccountsByUid(uid int64) ([]*models.Account, error)

GetAllAccountsByUid returns all account models of user

func (*AccountService) GetMaxDisplayOrder

func (s *AccountService) GetMaxDisplayOrder(uid int64, category models.AccountCategory) (int32, error)

GetMaxDisplayOrder returns the max display order according to account category

func (*AccountService) GetMaxSubAccountDisplayOrder

func (s *AccountService) GetMaxSubAccountDisplayOrder(uid int64, category models.AccountCategory, parentAccountId int64) (int32, error)

GetMaxSubAccountDisplayOrder returns the max display order of sub account according to account category and parent account id

func (*AccountService) GetSubAccountsByAccountId

func (s *AccountService) GetSubAccountsByAccountId(uid int64, accountId int64) ([]*models.Account, error)

GetSubAccountsByAccountId returns sub account models according to account id

func (*AccountService) GetTotalAccountCountByUid

func (s *AccountService) GetTotalAccountCountByUid(uid int64) (int64, error)

GetTotalAccountCountByUid returns total account count of user

func (*AccountService) HideAccount

func (s *AccountService) HideAccount(uid int64, ids []int64, hidden bool) error

HideAccount updates hidden field of given accounts

func (*AccountService) ModifyAccountDisplayOrders

func (s *AccountService) ModifyAccountDisplayOrders(uid int64, accounts []*models.Account) error

ModifyAccountDisplayOrders updates display order of given accounts

func (*AccountService) ModifyAccounts

func (s *AccountService) ModifyAccounts(uid int64, accounts []*models.Account) error

ModifyAccounts saves an existed account model to database

type ForgetPasswordService

type ForgetPasswordService struct {
	ServiceUsingConfig
	ServiceUsingMailer
}

ForgetPasswordService represents forget password service

func (*ForgetPasswordService) SendPasswordResetEmail

func (s *ForgetPasswordService) SendPasswordResetEmail(user *models.User, passwordResetToken string, backupLocale string) error

SendPasswordResetEmail sends password reset email according to specified parameters

type ServiceUsingConfig

type ServiceUsingConfig struct {
	// contains filtered or unexported fields
}

ServiceUsingConfig represents a service that need to use config

func (*ServiceUsingConfig) CurrentConfig

func (s *ServiceUsingConfig) CurrentConfig() *settings.Config

CurrentConfig returns the current config

type ServiceUsingDB

type ServiceUsingDB struct {
	// contains filtered or unexported fields
}

ServiceUsingDB represents a service that need to use db

func (*ServiceUsingDB) TokenDB

func (s *ServiceUsingDB) TokenDB(uid int64) *datastore.Database

TokenDB returns the datastore which contains user token

func (*ServiceUsingDB) UserDB

func (s *ServiceUsingDB) UserDB() *datastore.Database

UserDB returns the datastore which contains user

func (*ServiceUsingDB) UserDataDB

func (s *ServiceUsingDB) UserDataDB(uid int64) *datastore.Database

UserDataDB returns the datastore which contains user data

type ServiceUsingMailer

type ServiceUsingMailer struct {
	// contains filtered or unexported fields
}

ServiceUsingMailer represents a service that need to use mailer

func (*ServiceUsingMailer) SendMail

func (s *ServiceUsingMailer) SendMail(message *mail.MailMessage) error

SendMail sends an email according to argument

type ServiceUsingUuid

type ServiceUsingUuid struct {
	// contains filtered or unexported fields
}

ServiceUsingUuid represents a service that need to use uuid

func (*ServiceUsingUuid) GenerateUuid

func (s *ServiceUsingUuid) GenerateUuid(uuidType uuid.UuidType) int64

GenerateUuid generates a new uuid according to given uuid type

func (*ServiceUsingUuid) GenerateUuids

func (s *ServiceUsingUuid) GenerateUuids(uuidType uuid.UuidType, count uint8) []int64

GenerateUuids generates new uuids according to given uuid type and count

type TokenService

type TokenService struct {
	ServiceUsingDB
	ServiceUsingConfig
}

TokenService represents user token service

func (*TokenService) CreatePasswordResetToken

func (s *TokenService) CreatePasswordResetToken(user *models.User, ctx *core.Context) (string, *core.UserTokenClaims, error)

CreatePasswordResetToken generates a new password reset token and saves to database

func (*TokenService) CreateRequire2FAToken

func (s *TokenService) CreateRequire2FAToken(user *models.User, ctx *core.Context) (string, *core.UserTokenClaims, error)

CreateRequire2FAToken generates a new token requiring user to verify 2fa passcode and saves to database

func (*TokenService) CreateToken

func (s *TokenService) CreateToken(user *models.User, ctx *core.Context) (string, *core.UserTokenClaims, error)

CreateToken generates a new normal token and saves to database

func (*TokenService) DeleteToken

func (s *TokenService) DeleteToken(tokenRecord *models.TokenRecord) error

DeleteToken deletes given token from database

func (*TokenService) DeleteTokenByClaims

func (s *TokenService) DeleteTokenByClaims(claims *core.UserTokenClaims) error

DeleteTokenByClaims deletes given token from database

func (*TokenService) DeleteTokens

func (s *TokenService) DeleteTokens(uid int64, tokenRecords []*models.TokenRecord) error

DeleteTokens deletes given tokens from database

func (*TokenService) DeleteTokensBeforeTime

func (s *TokenService) DeleteTokensBeforeTime(uid int64, expireTime int64) error

DeleteTokensBeforeTime deletes tokens that is created before specific time

func (*TokenService) GenerateTokenId

func (s *TokenService) GenerateTokenId(tokenRecord *models.TokenRecord) string

GenerateTokenId generates token id according to token model

func (*TokenService) GetAllTokensByUid

func (s *TokenService) GetAllTokensByUid(uid int64) ([]*models.TokenRecord, error)

GetAllTokensByUid returns all token models of given user

func (*TokenService) GetAllUnexpiredNormalTokensByUid

func (s *TokenService) GetAllUnexpiredNormalTokensByUid(uid int64) ([]*models.TokenRecord, error)

GetAllUnexpiredNormalTokensByUid returns all available token models of given user

func (*TokenService) ParseFromTokenId

func (s *TokenService) ParseFromTokenId(tokenId string) (*models.TokenRecord, error)

ParseFromTokenId returns token model according to token id

func (*TokenService) ParseTokenByArgument

func (s *TokenService) ParseTokenByArgument(c *core.Context, tokenParameterName string) (*jwt.Token, *core.UserTokenClaims, error)

ParseTokenByArgument returns the token model according to request data

func (*TokenService) ParseTokenByCookie

func (s *TokenService) ParseTokenByCookie(c *core.Context, tokenCookieName string) (*jwt.Token, *core.UserTokenClaims, error)

ParseTokenByCookie returns the token model according to request data

func (*TokenService) ParseTokenByHeader

func (s *TokenService) ParseTokenByHeader(c *core.Context) (*jwt.Token, *core.UserTokenClaims, error)

ParseTokenByHeader returns the token model according to request data

type TransactionCategoryService

type TransactionCategoryService struct {
	ServiceUsingDB
	ServiceUsingUuid
}

TransactionCategoryService represents transaction category service

func (*TransactionCategoryService) CreateCategories

CreateCategories saves a few transaction category models to database

func (*TransactionCategoryService) CreateCategory

func (s *TransactionCategoryService) CreateCategory(category *models.TransactionCategory) error

CreateCategory saves a new transaction category model to database

func (*TransactionCategoryService) DeleteAllCategories

func (s *TransactionCategoryService) DeleteAllCategories(uid int64) error

DeleteAllCategories deletes all existed transaction categories from database

func (*TransactionCategoryService) DeleteCategory

func (s *TransactionCategoryService) DeleteCategory(uid int64, categoryId int64) error

DeleteCategory deletes an existed transaction category from database

func (*TransactionCategoryService) GetAllCategoriesByUid

func (s *TransactionCategoryService) GetAllCategoriesByUid(uid int64, categoryType models.TransactionCategoryType, parentCategoryId int64) ([]*models.TransactionCategory, error)

GetAllCategoriesByUid returns all transaction category models of user

func (*TransactionCategoryService) GetCategoriesByCategoryIds

func (s *TransactionCategoryService) GetCategoriesByCategoryIds(uid int64, categoryIds []int64) (map[int64]*models.TransactionCategory, error)

GetCategoriesByCategoryIds returns transaction category models according to transaction category ids

func (*TransactionCategoryService) GetCategoryByCategoryId

func (s *TransactionCategoryService) GetCategoryByCategoryId(uid int64, categoryId int64) (*models.TransactionCategory, error)

GetCategoryByCategoryId returns a transaction category model according to transaction category id

func (*TransactionCategoryService) GetCategoryMapByList

func (s *TransactionCategoryService) GetCategoryMapByList(categories []*models.TransactionCategory) map[int64]*models.TransactionCategory

GetCategoryMapByList returns a transaction category map by a list

func (*TransactionCategoryService) GetMaxDisplayOrder

func (s *TransactionCategoryService) GetMaxDisplayOrder(uid int64, categoryType models.TransactionCategoryType) (int32, error)

GetMaxDisplayOrder returns the max display order according to transaction category type

func (*TransactionCategoryService) GetMaxSubCategoryDisplayOrder

func (s *TransactionCategoryService) GetMaxSubCategoryDisplayOrder(uid int64, categoryType models.TransactionCategoryType, parentCategoryId int64) (int32, error)

GetMaxSubCategoryDisplayOrder returns the max display order of sub transaction category according to transaction category type and parent transaction category id

func (*TransactionCategoryService) GetTotalCategoryCountByUid

func (s *TransactionCategoryService) GetTotalCategoryCountByUid(uid int64) (int64, error)

GetTotalCategoryCountByUid returns total category count of user

func (*TransactionCategoryService) HideCategory

func (s *TransactionCategoryService) HideCategory(uid int64, ids []int64, hidden bool) error

HideCategory updates hidden field of given transaction categories

func (*TransactionCategoryService) ModifyCategory

func (s *TransactionCategoryService) ModifyCategory(category *models.TransactionCategory) error

ModifyCategory saves an existed transaction category model to database

func (*TransactionCategoryService) ModifyCategoryDisplayOrders

func (s *TransactionCategoryService) ModifyCategoryDisplayOrders(uid int64, categories []*models.TransactionCategory) error

ModifyCategoryDisplayOrders updates display order of given transaction categories

type TransactionService

type TransactionService struct {
	ServiceUsingDB
	ServiceUsingUuid
}

TransactionService represents transaction service

func (*TransactionService) CreateTransaction

func (s *TransactionService) CreateTransaction(transaction *models.Transaction, tagIds []int64) error

CreateTransaction saves a new transaction to database

func (*TransactionService) DeleteAllTransactions

func (s *TransactionService) DeleteAllTransactions(uid int64) error

DeleteAllTransactions deletes all existed transactions from database

func (*TransactionService) DeleteTransaction

func (s *TransactionService) DeleteTransaction(uid int64, transactionId int64) error

DeleteTransaction deletes an existed transaction from database

func (*TransactionService) GetAccountsAndCategoriesTotalIncomeAndExpense

func (s *TransactionService) GetAccountsAndCategoriesTotalIncomeAndExpense(uid int64, startUnixTime int64, endUnixTime int64) ([]*models.Transaction, error)

GetAccountsAndCategoriesTotalIncomeAndExpense returns the every accounts and categories total income and expense amount by specific date range

func (*TransactionService) GetAccountsMonthTotalIncomeAndExpense

func (s *TransactionService) GetAccountsMonthTotalIncomeAndExpense(uid int64, startUnixTime int64, endUnixTime int64, pageCount int) (map[string]models.TransactionAccountsAmount, error)

GetAccountsMonthTotalIncomeAndExpense returns the every accounts total income and expense amount in month by specific date range

func (*TransactionService) GetAccountsTotalIncomeAndExpense

func (s *TransactionService) GetAccountsTotalIncomeAndExpense(uid int64, startUnixTime int64, endUnixTime int64) (map[int64]int64, map[int64]int64, error)

GetAccountsTotalIncomeAndExpense returns the every accounts total income and expense amount by specific date range

func (*TransactionService) GetAllTransactionCount

func (s *TransactionService) GetAllTransactionCount(uid int64) (int64, error)

GetAllTransactionCount returns total count of transactions

func (*TransactionService) GetAllTransactions

func (s *TransactionService) GetAllTransactions(uid int64, pageCount int32, noDuplicated bool) ([]*models.Transaction, error)

GetAllTransactions returns all transactions

func (*TransactionService) GetAllTransactionsByMaxTime

func (s *TransactionService) GetAllTransactionsByMaxTime(uid int64, maxTransactionTime int64, count int32, noDuplicated bool) ([]*models.Transaction, error)

GetAllTransactionsByMaxTime returns all transactions before given time

func (*TransactionService) GetMonthTransactionCount

func (s *TransactionService) GetMonthTransactionCount(uid int64, year int32, month int32, transactionType models.TransactionDbType, categoryIds []int64, accountIds []int64, keyword string, utcOffset int16) (int64, error)

GetMonthTransactionCount returns total count of transactions in given year and month

func (*TransactionService) GetRelatedTransferTransaction

func (s *TransactionService) GetRelatedTransferTransaction(originalTransaction *models.Transaction) *models.Transaction

GetRelatedTransferTransaction returns the related transaction for transfer transaction

func (*TransactionService) GetTotalTransactionCountByUid

func (s *TransactionService) GetTotalTransactionCountByUid(uid int64) (int64, error)

GetTotalTransactionCountByUid returns total transaction count of user

func (*TransactionService) GetTransactionByTransactionId

func (s *TransactionService) GetTransactionByTransactionId(uid int64, transactionId int64) (*models.Transaction, error)

GetTransactionByTransactionId returns a transaction model according to transaction id

func (*TransactionService) GetTransactionCount

func (s *TransactionService) GetTransactionCount(uid int64, maxTransactionTime int64, minTransactionTime int64, transactionType models.TransactionDbType, categoryIds []int64, accountIds []int64, keyword string) (int64, error)

GetTransactionCount returns count of transactions

func (*TransactionService) GetTransactionMapByList

func (s *TransactionService) GetTransactionMapByList(transactions []*models.Transaction) map[int64]*models.Transaction

GetTransactionMapByList returns a transaction map by a list

func (*TransactionService) GetTransactionsByMaxTime

func (s *TransactionService) GetTransactionsByMaxTime(uid int64, maxTransactionTime int64, minTransactionTime int64, transactionType models.TransactionDbType, categoryIds []int64, accountIds []int64, keyword string, page int32, count int32, needOneMoreItem bool, noDuplicated bool) ([]*models.Transaction, error)

GetTransactionsByMaxTime returns transactions before given time

func (*TransactionService) GetTransactionsInMonthByPage

func (s *TransactionService) GetTransactionsInMonthByPage(uid int64, year int32, month int32, transactionType models.TransactionDbType, categoryIds []int64, accountIds []int64, keyword string) ([]*models.Transaction, error)

GetTransactionsInMonthByPage returns all transactions in given year and month

func (*TransactionService) ModifyTransaction

func (s *TransactionService) ModifyTransaction(transaction *models.Transaction, addTagIds []int64, removeTagIds []int64) error

ModifyTransaction saves an existed transaction to database

type TransactionTagService

type TransactionTagService struct {
	ServiceUsingDB
	ServiceUsingUuid
}

TransactionTagService represents transaction tag service

func (*TransactionTagService) CreateTag

func (s *TransactionTagService) CreateTag(tag *models.TransactionTag) error

CreateTag saves a new transaction tag model to database

func (*TransactionTagService) DeleteAllTags

func (s *TransactionTagService) DeleteAllTags(uid int64) error

DeleteAllTags deletes all existed transaction tags from database

func (*TransactionTagService) DeleteTag

func (s *TransactionTagService) DeleteTag(uid int64, tagId int64) error

DeleteTag deletes an existed transaction tag from database

func (*TransactionTagService) ExistsTagName

func (s *TransactionTagService) ExistsTagName(uid int64, name string) (bool, error)

ExistsTagName returns whether the given tag name exists

func (*TransactionTagService) GetAllTagIdsOfAllTransactions

func (s *TransactionTagService) GetAllTagIdsOfAllTransactions(uid int64) (map[int64][]int64, error)

GetAllTagIdsOfAllTransactions returns all transaction tag ids

func (*TransactionTagService) GetAllTagIdsOfTransactions

func (s *TransactionTagService) GetAllTagIdsOfTransactions(uid int64, transactionIds []int64) (map[int64][]int64, error)

GetAllTagIdsOfTransactions returns transaction tag ids for given transactions

func (*TransactionTagService) GetAllTagsByUid

func (s *TransactionTagService) GetAllTagsByUid(uid int64) ([]*models.TransactionTag, error)

GetAllTagsByUid returns all transaction tag models of user

func (*TransactionTagService) GetMaxDisplayOrder

func (s *TransactionTagService) GetMaxDisplayOrder(uid int64) (int32, error)

GetMaxDisplayOrder returns the max display order

func (*TransactionTagService) GetTagByTagId

func (s *TransactionTagService) GetTagByTagId(uid int64, tagId int64) (*models.TransactionTag, error)

GetTagByTagId returns a transaction tag model according to transaction tag id

func (*TransactionTagService) GetTagMapByList

func (s *TransactionTagService) GetTagMapByList(tags []*models.TransactionTag) map[int64]*models.TransactionTag

GetTagMapByList returns a transaction tag map by a list

func (*TransactionTagService) GetTagsByTagIds

func (s *TransactionTagService) GetTagsByTagIds(uid int64, tagIds []int64) (map[int64]*models.TransactionTag, error)

GetTagsByTagIds returns transaction tag models according to transaction tag ids

func (*TransactionTagService) GetTotalTagCountByUid

func (s *TransactionTagService) GetTotalTagCountByUid(uid int64) (int64, error)

GetTotalTagCountByUid returns total tag count of user

func (*TransactionTagService) HideTag

func (s *TransactionTagService) HideTag(uid int64, ids []int64, hidden bool) error

HideTag updates hidden field of given transaction tags

func (*TransactionTagService) ModifyTag

func (s *TransactionTagService) ModifyTag(tag *models.TransactionTag) error

ModifyTag saves an existed transaction tag model to database

func (*TransactionTagService) ModifyTagDisplayOrders

func (s *TransactionTagService) ModifyTagDisplayOrders(uid int64, tags []*models.TransactionTag) error

ModifyTagDisplayOrders updates display order of given transaction tags

type TwoFactorAuthorizationService

type TwoFactorAuthorizationService struct {
	ServiceUsingDB
	ServiceUsingConfig
	ServiceUsingUuid
}

TwoFactorAuthorizationService represents 2fa service

func (*TwoFactorAuthorizationService) CreateTwoFactorRecoveryCodes

func (s *TwoFactorAuthorizationService) CreateTwoFactorRecoveryCodes(uid int64, recoveryCodes []string, salt string) error

CreateTwoFactorRecoveryCodes saves new 2fa recovery codes to database

func (*TwoFactorAuthorizationService) CreateTwoFactorSetting

func (s *TwoFactorAuthorizationService) CreateTwoFactorSetting(twoFactor *models.TwoFactor) error

CreateTwoFactorSetting saves a new 2fa setting to database

func (*TwoFactorAuthorizationService) DeleteTwoFactorRecoveryCodes

func (s *TwoFactorAuthorizationService) DeleteTwoFactorRecoveryCodes(uid int64) error

DeleteTwoFactorRecoveryCodes deletes existed 2fa recovery codes from database

func (*TwoFactorAuthorizationService) DeleteTwoFactorSetting

func (s *TwoFactorAuthorizationService) DeleteTwoFactorSetting(uid int64) error

DeleteTwoFactorSetting deletes an existed 2fa setting from database

func (*TwoFactorAuthorizationService) ExistsTwoFactorSetting

func (s *TwoFactorAuthorizationService) ExistsTwoFactorSetting(uid int64) (bool, error)

ExistsTwoFactorSetting returns whether the given user has existed 2fa setting

func (*TwoFactorAuthorizationService) GenerateTwoFactorRecoveryCodes

func (s *TwoFactorAuthorizationService) GenerateTwoFactorRecoveryCodes() ([]string, error)

GenerateTwoFactorRecoveryCodes generates new 2fa recovery codes

func (*TwoFactorAuthorizationService) GenerateTwoFactorSecret

func (s *TwoFactorAuthorizationService) GenerateTwoFactorSecret(user *models.User) (*otp.Key, error)

GenerateTwoFactorSecret generates a new 2fa secret

func (*TwoFactorAuthorizationService) GetAndUseUserTwoFactorRecoveryCode

func (s *TwoFactorAuthorizationService) GetAndUseUserTwoFactorRecoveryCode(uid int64, recoveryCode string, salt string) error

GetAndUseUserTwoFactorRecoveryCode checks whether the given 2fa recovery code exists and marks it used

func (*TwoFactorAuthorizationService) GetUserTwoFactorSettingByUid

func (s *TwoFactorAuthorizationService) GetUserTwoFactorSettingByUid(uid int64) (*models.TwoFactor, error)

GetUserTwoFactorSettingByUid returns the 2fa setting model according to user uid

type UserService

type UserService struct {
	ServiceUsingDB
	ServiceUsingUuid
}

UserService represents user service

func (*UserService) CreateUser

func (s *UserService) CreateUser(user *models.User) error

CreateUser saves a new user model to database

func (*UserService) DeleteUser

func (s *UserService) DeleteUser(username string) error

DeleteUser deletes an existed user from database

func (*UserService) DisableUser

func (s *UserService) DisableUser(username string) error

DisableUser sets user disabled

func (*UserService) EnableUser

func (s *UserService) EnableUser(username string) error

EnableUser sets user enabled

func (*UserService) ExistsEmail

func (s *UserService) ExistsEmail(email string) (bool, error)

ExistsEmail returns whether the given user email exists

func (*UserService) ExistsUsername

func (s *UserService) ExistsUsername(username string) (bool, error)

ExistsUsername returns whether the given user name exists

func (*UserService) GetUserByEmail

func (s *UserService) GetUserByEmail(email string) (*models.User, error)

GetUserByEmail returns the user model according to user email

func (*UserService) GetUserById

func (s *UserService) GetUserById(uid int64) (*models.User, error)

GetUserById returns the user model according to user uid

func (*UserService) GetUserByUsername

func (s *UserService) GetUserByUsername(username string) (*models.User, error)

GetUserByUsername returns the user model according to user name

func (*UserService) GetUserByUsernameOrEmailAndPassword

func (s *UserService) GetUserByUsernameOrEmailAndPassword(loginname string, password string) (*models.User, error)

GetUserByUsernameOrEmailAndPassword returns the user model according to login name and password

func (*UserService) IsPasswordEqualsUserPassword

func (s *UserService) IsPasswordEqualsUserPassword(password string, user *models.User) bool

IsPasswordEqualsUserPassword returns whether the given password is correct

func (*UserService) SetUserEmailUnverified

func (s *UserService) SetUserEmailUnverified(username string) error

SetUserEmailUnverified sets user email address unverified

func (*UserService) SetUserEmailVerified

func (s *UserService) SetUserEmailVerified(username string) error

SetUserEmailVerified sets user email address verified

func (*UserService) UpdateUser

func (s *UserService) UpdateUser(user *models.User, modifyUserLanguage bool) (keyProfileUpdated bool, err error)

UpdateUser saves an existed user model to database

func (*UserService) UpdateUserLastLoginTime

func (s *UserService) UpdateUserLastLoginTime(uid int64) error

UpdateUserLastLoginTime updates the last login time field

Jump to

Keyboard shortcuts

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