Skip to content

Commit

Permalink
fix: init default captcha provider (casdoor#810)
Browse files Browse the repository at this point in the history
* feat: init built in provider

* Update built-in provider in application

* Delete unnecessary judge

* Update init.go

Co-authored-by: Gucheng <[email protected]>
  • Loading branch information
Resulte and nomeguy authored Jun 21, 2022
1 parent 376bac1 commit 460a4d4
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion object/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
func InitDb() {
existed := initBuiltInOrganization()
if !existed {
initBuiltInProvider()
initBuiltInUser()
initBuiltInApplication()
initBuiltInCert()
Expand Down Expand Up @@ -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"},
Expand Down Expand Up @@ -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)
}

0 comments on commit 460a4d4

Please sign in to comment.