From 460a4d496954f1d0abfe571630a1ba7316fb0f97 Mon Sep 17 00:00:00 2001 From: Resulte Lee Date: Wed, 22 Jun 2022 00:03:55 +0800 Subject: [PATCH] fix: init default captcha provider (#810) * feat: init built in provider * Update built-in provider in application * Delete unnecessary judge * Update init.go Co-authored-by: Gucheng <85475922+nomeguy@users.noreply.github.com> --- object/init.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/object/init.go b/object/init.go index 917bdd71..84399339 100644 --- a/object/init.go +++ b/object/init.go @@ -23,6 +23,7 @@ import ( func InitDb() { existed := initBuiltInOrganization() if !existed { + initBuiltInProvider() initBuiltInUser() initBuiltInApplication() initBuiltInCert() @@ -127,7 +128,9 @@ func initBuiltInApplication() { Cert: "cert-built-in", EnablePassword: true, EnableSignUp: true, - Providers: []*ProviderItem{}, + Providers: []*ProviderItem{ + {Name: "provider_captcha_default", CanSignUp: false, CanSignIn: false, CanUnlink: false, Prompted: false, AlertType: "None", Provider: nil}, + }, SignupItems: []*SignupItem{ {Name: "ID", Visible: false, Required: true, Prompted: false, Rule: "Random"}, {Name: "Username", Visible: true, Required: true, Prompted: false, Rule: "None"}, @@ -201,3 +204,20 @@ func initBuiltInLdap() { } AddLdap(ldap) } + +func initBuiltInProvider() { + provider := GetProvider("admin/provider_captcha_default") + if provider != nil { + return + } + + provider = &Provider{ + Owner: "admin", + Name: "provider_captcha_default", + CreatedTime: util.GetCurrentTime(), + DisplayName: "Captcha Default", + Category: "Captcha", + Type: "Default", + } + AddProvider(provider) +}