helper

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckDisable

func CheckDisable(tokenValue string) error

CheckDisable checks if the account associated with the token is disabled | 检查Token对应账号是否被封禁

func CheckLogin

func CheckLogin(tokenValue string) error

CheckLogin checks login status (throws error if not logged in) | 检查登录状态(未登录抛出错误)

func CheckPermission

func CheckPermission(tokenValue string, permission string) error

CheckPermission checks if the token has the specified permission | 检查Token是否拥有指定权限

func CheckPermissionAnd

func CheckPermissionAnd(tokenValue string, permissions []string) error

CheckPermissionAnd checks if the token has all specified permissions | 检查Token是否拥有所有指定权限

func CheckPermissionOr

func CheckPermissionOr(tokenValue string, permissions []string) error

CheckPermissionOr checks if the token has any of the specified permissions | 检查Token是否拥有任一指定权限

func CheckRole

func CheckRole(tokenValue string, role string) error

CheckRole checks if the token has the specified role | 检查Token是否拥有指定角色

func CheckRoleAnd

func CheckRoleAnd(tokenValue string, roles []string) error

CheckRoleAnd checks if the token has all specified roles | 检查Token是否拥有所有指定角色

func CheckRoleOr

func CheckRoleOr(tokenValue string, roles []string) error

CheckRoleOr checks if the token has any of the specified roles | 检查Token是否拥有任一指定角色

func CloseManager

func CloseManager()

CloseManager closes global Manager and releases resources | 关闭全局 Manager 并释放资源

func DeleteSession

func DeleteSession(loginID interface{}) error

DeleteSession deletes a session | 删除Session

func Disable

func Disable(loginID interface{}, duration time.Duration) error

Disable disables an account for specified duration | 封禁账号(指定时长)

func GenerateNonce

func GenerateNonce() (string, error)

func GetDisableTime

func GetDisableTime(loginID interface{}) (int64, error)

GetDisableTime gets remaining disable time in seconds | 获取剩余封禁时间(秒)

func GetLoginID

func GetLoginID(tokenValue string) (string, error)

GetLoginID gets the login ID from token | 从Token获取登录ID

func GetLoginIDNotCheck

func GetLoginIDNotCheck(tokenValue string) (string, error)

GetLoginIDNotCheck gets login ID without checking | 获取登录ID(不检查)

func GetManager

func GetManager() *manager.Manager

GetManager gets the global Manager | 获取全局Manager

func GetOAuth2Server

func GetOAuth2Server() *oauth2.OAuth2Server

func GetPermissionList

func GetPermissionList(tokenValue string) ([]string, error)

GetPermissionList gets permission list for the token | 获取Token对应的权限列表

func GetPermissions

func GetPermissions(loginID interface{}) ([]string, error)

GetPermissions gets permission list | 获取权限列表

func GetRoleList

func GetRoleList(tokenValue string) ([]string, error)

GetRoleList gets role list for the token | 获取Token对应的角色列表

func GetRoles

func GetRoles(loginID interface{}) ([]string, error)

GetRoles gets role list | 获取角色列表

func GetSession

func GetSession(loginID interface{}) (*session.Session, error)

GetSession gets session by login ID | 根据登录ID获取Session

func GetSessionByToken

func GetSessionByToken(tokenValue string) (*session.Session, error)

GetSessionByToken gets session by token | 根据Token获取Session

func GetSessionCount

func GetSessionCount(loginID interface{}) (int, error)

GetSessionCount 获取指定账号的Session数量

func GetTokenInfo

func GetTokenInfo(tokenValue string) (*manager.TokenInfo, error)

GetTokenInfo gets token information | 获取Token信息

func GetTokenSession

func GetTokenSession(tokenValue string) (*session.Session, error)

GetTokenSession gets session for the token | 获取Token对应的Session

func GetTokenTag

func GetTokenTag(tokenValue string) (string, error)

GetTokenTag 获取Token标签

func GetTokenValue

func GetTokenValue(loginID interface{}, device ...string) (string, error)

GetTokenValue gets the token value for a login ID | 获取登录ID对应的Token值

func GetTokenValueList

func GetTokenValueList(loginID interface{}) ([]string, error)

GetTokenValueList 获取指定账号的所有Token

func HasPermission

func HasPermission(loginID interface{}, permission string) bool

HasPermission checks if has specified permission | 检查是否拥有指定权限

func HasPermissionsAnd

func HasPermissionsAnd(loginID interface{}, permissions []string) bool

HasPermissionsAnd checks if has all permissions (AND logic) | 检查是否拥有所有权限(AND逻辑)

func HasPermissionsOr

func HasPermissionsOr(loginID interface{}, permissions []string) bool

HasPermissionsOr checks if has any permission (OR logic) | 检查是否拥有任一权限(OR逻辑)

func HasRole

func HasRole(loginID interface{}, role string) bool

HasRole checks if has specified role | 检查是否拥有指定角色

func HasRolesAnd

func HasRolesAnd(loginID interface{}, roles []string) bool

HasRolesAnd checks if has all roles (AND logic) | 检查是否拥有所有角色(AND逻辑)

func HasRolesOr

func HasRolesOr(loginID interface{}, roles []string) bool

HasRolesOr 检查是否拥有任一角色(OR)

func IsDisable

func IsDisable(loginID interface{}) bool

IsDisable checks if an account is disabled | 检查账号是否被封禁

func IsLogin

func IsLogin(tokenValue string) bool

IsLogin checks if the user is logged in | 检查用户是否已登录

func Kickout

func Kickout(loginID interface{}, device ...string) error

Kickout kicks out a user session | 踢人下线

func Login

func Login(loginID interface{}, device ...string) (string, error)

Login performs user login | 用户登录

func LoginByToken

func LoginByToken(loginID interface{}, tokenValue string, device ...string) error

LoginByToken performs login with specified token | 使用指定Token登录

func LoginWithRefreshToken

func LoginWithRefreshToken(loginID interface{}, device ...string) (*security.RefreshTokenInfo, error)

func Logout

func Logout(loginID interface{}, device ...string) error

Logout performs user logout | 用户登出

func LogoutByToken

func LogoutByToken(tokenValue string) error

LogoutByToken performs logout by token | 根据Token登出

func RefreshAccessToken

func RefreshAccessToken(refreshToken string) (*security.RefreshTokenInfo, error)

func RevokeRefreshToken

func RevokeRefreshToken(refreshToken string) error

func SetManager

func SetManager(mgr *manager.Manager)

SetManager sets the global Manager (must be called first) | 设置全局Manager(必须先调用此方法)

func SetPermissions

func SetPermissions(loginID interface{}, permissions []string) error

SetPermissions sets permissions for a login ID | 设置用户权限

func SetRoles

func SetRoles(loginID interface{}, roles []string) error

SetRoles sets roles for a login ID | 设置用户角色

func SetTokenTag

func SetTokenTag(tokenValue, tag string) error

SetTokenTag 设置Token标签

func Untie

func Untie(loginID interface{}) error

Untie re-enables a disabled account | 解封账号

func VerifyNonce

func VerifyNonce(nonce string) bool

Types

This section is empty.

Jump to

Keyboard shortcuts

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