examples

package
v1.1.12 Latest Latest
Warning

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

Go to latest
Published: May 27, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateRandomString

func GenerateRandomString(length int) string

GenerateRandomString 生成指定长度的随机字符串

func SetupSocialLogin

func SetupSocialLogin(app *flow.Engine)

SetupSocialLogin 设置社交登录

Types

type SocialUserRepository

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

SocialUserRepository 是社交用户存储库示例

func NewSocialUserRepository

func NewSocialUserRepository() *SocialUserRepository

NewSocialUserRepository 创建新的社交用户存储库

func (*SocialUserRepository) CreateUser

func (r *SocialUserRepository) CreateUser(ctx context.Context, user interface{}) error

CreateUser 创建新用户

func (*SocialUserRepository) FindUserBySocialID

func (r *SocialUserRepository) FindUserBySocialID(ctx context.Context, provider, socialID string) (interface{}, error)

FindUserBySocialID 通过社交ID查找用户

func (*SocialUserRepository) SaveUser

func (r *SocialUserRepository) SaveUser(user *User)

SaveUser 保存用户

type User

type User struct {
	ID          string
	Username    string
	Email       string
	Avatar      string
	Password    string
	Provider    string
	ProviderID  string
	Roles       []string
	Permissions []string
	IsActive    bool
}

User 是一个用户模型示例

func (*User) GetAuthIdentifier

func (u *User) GetAuthIdentifier() string

GetAuthIdentifier 实现 Authenticatable 接口

func (*User) GetAuthUsername

func (u *User) GetAuthUsername() string

GetAuthUsername 实现 Authenticatable 接口

func (*User) GetPermissions

func (u *User) GetPermissions() []string

GetPermissions 实现 Authenticatable 接口

func (*User) GetRoles

func (u *User) GetRoles() []string

GetRoles 实现 Authenticatable 接口

type UserRepository

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

UserRepository 是用户存储库示例

func NewUserRepository

func NewUserRepository() *UserRepository

NewUserRepository 创建新的用户存储库

func (*UserRepository) FindByCredentials

func (r *UserRepository) FindByCredentials(ctx context.Context, credentials map[string]string) (auth.Authenticatable, error)

FindByCredentials 通过凭证查找用户

func (*UserRepository) FindByID

func (r *UserRepository) FindByID(ctx context.Context, id string) (auth.Authenticatable, error)

FindByID 通过ID查找用户

func (*UserRepository) SaveUser

func (r *UserRepository) SaveUser(user *User)

SaveUser 保存用户

func (*UserRepository) ValidateCredentials

func (r *UserRepository) ValidateCredentials(ctx context.Context, user auth.Authenticatable, credentials map[string]string) (bool, error)

ValidateCredentials 验证用户凭证

Jump to

Keyboard shortcuts

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