feat: 增加 GitHub 和 Google 邮箱快捷登录
This commit is contained in:
@@ -2121,6 +2121,8 @@ type oauthPendingFlowTestHandlerOptions struct {
|
||||
emailCache service.EmailCache
|
||||
settingValues map[string]string
|
||||
defaultSubAssigner service.DefaultSubscriptionAssigner
|
||||
affiliateService *service.AffiliateService
|
||||
affiliateFactory func(*dbent.Client, *service.SettingService) *service.AffiliateService
|
||||
totpCache service.TotpCache
|
||||
totpEncryptor service.SecretEncryptor
|
||||
userRepoOptions oauthPendingFlowUserRepoOptions
|
||||
@@ -2160,6 +2162,21 @@ CREATE TABLE IF NOT EXISTS user_avatars (
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
)`)
|
||||
require.NoError(t, err)
|
||||
_, err = db.Exec(`
|
||||
CREATE TABLE IF NOT EXISTS user_affiliates (
|
||||
user_id INTEGER PRIMARY KEY,
|
||||
aff_code TEXT NOT NULL UNIQUE,
|
||||
aff_code_custom BOOLEAN NOT NULL DEFAULT false,
|
||||
aff_rebate_rate_percent REAL NULL,
|
||||
inviter_id INTEGER NULL,
|
||||
aff_count INTEGER NOT NULL DEFAULT 0,
|
||||
aff_quota REAL NOT NULL DEFAULT 0,
|
||||
aff_frozen_quota REAL NOT NULL DEFAULT 0,
|
||||
aff_history_quota REAL NOT NULL DEFAULT 0,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
)`)
|
||||
require.NoError(t, err)
|
||||
|
||||
drv := entsql.OpenDB(dialect.SQLite, db)
|
||||
client := enttest.NewClient(t, enttest.WithOptions(dbent.Driver(drv)))
|
||||
@@ -2177,14 +2194,19 @@ CREATE TABLE IF NOT EXISTS user_avatars (
|
||||
},
|
||||
}
|
||||
settingValues := map[string]string{
|
||||
service.SettingKeyRegistrationEnabled: "true",
|
||||
service.SettingKeyInvitationCodeEnabled: boolSettingValue(options.invitationEnabled),
|
||||
service.SettingKeyEmailVerifyEnabled: boolSettingValue(options.emailVerifyEnabled),
|
||||
service.SettingKeyRegistrationEnabled: "true",
|
||||
service.SettingKeyInvitationCodeEnabled: boolSettingValue(options.invitationEnabled),
|
||||
service.SettingKeyEmailVerifyEnabled: boolSettingValue(options.emailVerifyEnabled),
|
||||
service.SettingKeyRegistrationEmailSuffixWhitelist: "[]",
|
||||
}
|
||||
for key, value := range options.settingValues {
|
||||
settingValues[key] = value
|
||||
}
|
||||
settingSvc := service.NewSettingService(&oauthPendingFlowSettingRepoStub{values: settingValues}, cfg)
|
||||
affiliateService := options.affiliateService
|
||||
if affiliateService == nil && options.affiliateFactory != nil {
|
||||
affiliateService = options.affiliateFactory(client, settingSvc)
|
||||
}
|
||||
userRepo := &oauthPendingFlowUserRepo{
|
||||
client: client,
|
||||
options: options.userRepoOptions,
|
||||
@@ -2210,7 +2232,7 @@ CREATE TABLE IF NOT EXISTS user_avatars (
|
||||
nil,
|
||||
nil,
|
||||
options.defaultSubAssigner,
|
||||
nil,
|
||||
affiliateService,
|
||||
)
|
||||
userSvc := service.NewUserService(userRepo, nil, nil, nil)
|
||||
var totpSvc *service.TotpService
|
||||
|
||||
Reference in New Issue
Block a user