mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-19 04:13:50 +08:00
Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
572616d390 | |||
2187310dbc | |||
26345bb21b | |||
e0455df504 | |||
1dfbbf0e90 | |||
d43d58dee2 | |||
9eb4b12041 | |||
3a45a4ee77 | |||
43393f034b | |||
bafa80513b | |||
8d08140421 | |||
3d29e27d54 | |||
199f1d4d10 | |||
227e938db6 | |||
739cfd84ed |
@ -295,7 +295,7 @@ func (c *ApiController) SendVerificationCode() {
|
|||||||
vform.CountryCode = mfaProps.CountryCode
|
vform.CountryCode = mfaProps.CountryCode
|
||||||
}
|
}
|
||||||
|
|
||||||
provider, err = application.GetSmsProvider(vform.Method)
|
provider, err = application.GetSmsProvider(vform.Method, vform.CountryCode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.ResponseError(err.Error())
|
c.ResponseError(err.Error())
|
||||||
return
|
return
|
||||||
|
4
go.mod
4
go.mod
@ -9,7 +9,7 @@ require (
|
|||||||
github.com/beego/beego v1.12.12
|
github.com/beego/beego v1.12.12
|
||||||
github.com/beevik/etree v1.1.0
|
github.com/beevik/etree v1.1.0
|
||||||
github.com/casbin/casbin/v2 v2.77.2
|
github.com/casbin/casbin/v2 v2.77.2
|
||||||
github.com/casdoor/go-sms-sender v0.20.0
|
github.com/casdoor/go-sms-sender v0.22.0
|
||||||
github.com/casdoor/gomail/v2 v2.0.1
|
github.com/casdoor/gomail/v2 v2.0.1
|
||||||
github.com/casdoor/notify v0.45.0
|
github.com/casdoor/notify v0.45.0
|
||||||
github.com/casdoor/oss v1.6.0
|
github.com/casdoor/oss v1.6.0
|
||||||
@ -45,7 +45,7 @@ require (
|
|||||||
github.com/robfig/cron/v3 v3.0.1
|
github.com/robfig/cron/v3 v3.0.1
|
||||||
github.com/russellhaering/gosaml2 v0.9.0
|
github.com/russellhaering/gosaml2 v0.9.0
|
||||||
github.com/russellhaering/goxmldsig v1.2.0
|
github.com/russellhaering/goxmldsig v1.2.0
|
||||||
github.com/sendgrid/sendgrid-go v3.14.0+incompatible // indirect
|
github.com/sendgrid/sendgrid-go v3.14.0+incompatible
|
||||||
github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18 // indirect
|
github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18 // indirect
|
||||||
github.com/shirou/gopsutil v3.21.11+incompatible
|
github.com/shirou/gopsutil v3.21.11+incompatible
|
||||||
github.com/siddontang/go-log v0.0.0-20190221022429-1e957dd83bed
|
github.com/siddontang/go-log v0.0.0-20190221022429-1e957dd83bed
|
||||||
|
4
go.sum
4
go.sum
@ -1083,8 +1083,8 @@ github.com/casbin/casbin/v2 v2.77.2 h1:yQinn/w9x8AswiwqwtrXz93VU48R1aYTXdHEx4RI3
|
|||||||
github.com/casbin/casbin/v2 v2.77.2/go.mod h1:mzGx0hYW9/ksOSpw3wNjk3NRAroq5VMFYUQ6G43iGPk=
|
github.com/casbin/casbin/v2 v2.77.2/go.mod h1:mzGx0hYW9/ksOSpw3wNjk3NRAroq5VMFYUQ6G43iGPk=
|
||||||
github.com/casdoor/go-reddit/v2 v2.1.0 h1:kIbfdJ7AA7H0uTQ8s0q4GGZqSS5V9wVE74RrXyD9XPs=
|
github.com/casdoor/go-reddit/v2 v2.1.0 h1:kIbfdJ7AA7H0uTQ8s0q4GGZqSS5V9wVE74RrXyD9XPs=
|
||||||
github.com/casdoor/go-reddit/v2 v2.1.0/go.mod h1:eagkvwlZ4Hcsuc/uQsLHYEulz5jN65SVSwV/AIE7zsc=
|
github.com/casdoor/go-reddit/v2 v2.1.0/go.mod h1:eagkvwlZ4Hcsuc/uQsLHYEulz5jN65SVSwV/AIE7zsc=
|
||||||
github.com/casdoor/go-sms-sender v0.20.0 h1:yLbCakV04DzzehhgBklOrSeCFjMwpfKBeemz9b+Y8OM=
|
github.com/casdoor/go-sms-sender v0.22.0 h1:K4vj6IZgSESNvs8HchI5CIowvXHNpm7rXOV9QnCTZL4=
|
||||||
github.com/casdoor/go-sms-sender v0.20.0/go.mod h1:cQs7qqohMJBgIVZebOCB8ko09naG1vzFJEH59VNIscs=
|
github.com/casdoor/go-sms-sender v0.22.0/go.mod h1:cQs7qqohMJBgIVZebOCB8ko09naG1vzFJEH59VNIscs=
|
||||||
github.com/casdoor/gomail/v2 v2.0.1 h1:J+FG6x80s9e5lBHUn8Sv0Y56mud34KiWih5YdmudR/w=
|
github.com/casdoor/gomail/v2 v2.0.1 h1:J+FG6x80s9e5lBHUn8Sv0Y56mud34KiWih5YdmudR/w=
|
||||||
github.com/casdoor/gomail/v2 v2.0.1/go.mod h1:VnGPslEAtpix5FjHisR/WKB1qvZDBaujbikxDe9d+2Q=
|
github.com/casdoor/gomail/v2 v2.0.1/go.mod h1:VnGPslEAtpix5FjHisR/WKB1qvZDBaujbikxDe9d+2Q=
|
||||||
github.com/casdoor/notify v0.45.0 h1:OlaFvcQFjGOgA4mRx07M8AH1gvb5xNo21mcqrVGlLgk=
|
github.com/casdoor/notify v0.45.0 h1:OlaFvcQFjGOgA4mRx07M8AH1gvb5xNo21mcqrVGlLgk=
|
||||||
|
@ -670,11 +670,7 @@ func AddApplication(application *Application) (bool, error) {
|
|||||||
return affected != 0, nil
|
return affected != 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteApplication(application *Application) (bool, error) {
|
func deleteApplication(application *Application) (bool, error) {
|
||||||
if application.Name == "app-built-in" {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
affected, err := ormer.Engine.ID(core.PK{application.Owner, application.Name}).Delete(&Application{})
|
affected, err := ormer.Engine.ID(core.PK{application.Owner, application.Name}).Delete(&Application{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
@ -683,6 +679,14 @@ func DeleteApplication(application *Application) (bool, error) {
|
|||||||
return affected != 0, nil
|
return affected != 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DeleteApplication(application *Application) (bool, error) {
|
||||||
|
if application.Name == "app-built-in" {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return deleteApplication(application)
|
||||||
|
}
|
||||||
|
|
||||||
func (application *Application) GetId() string {
|
func (application *Application) GetId() string {
|
||||||
return fmt.Sprintf("%s/%s", application.Owner, application.Name)
|
return fmt.Sprintf("%s/%s", application.Owner, application.Name)
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,20 @@ func (application *Application) GetProviderByCategory(category string) (*Provide
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (application *Application) GetProviderByCategoryAndRule(category string, method string) (*Provider, error) {
|
func isProviderItemCountryCodeMatched(providerItem *ProviderItem, countryCode string) bool {
|
||||||
|
if len(providerItem.CountryCodes) == 0 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, countryCode2 := range providerItem.CountryCodes {
|
||||||
|
if countryCode2 == "" || countryCode2 == "All" || countryCode2 == "all" || countryCode2 == countryCode {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (application *Application) GetProviderByCategoryAndRule(category string, method string, countryCode string) (*Provider, error) {
|
||||||
providers, err := GetProviders(application.Organization)
|
providers, err := GetProviders(application.Organization)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -54,7 +67,13 @@ func (application *Application) GetProviderByCategoryAndRule(category string, me
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, providerItem := range application.Providers {
|
for _, providerItem := range application.Providers {
|
||||||
if providerItem.Rule == method || (providerItem.Rule == "all" || providerItem.Rule == "" || providerItem.Rule == "None") {
|
if providerItem.Provider != nil && providerItem.Provider.Category == "SMS" {
|
||||||
|
if !isProviderItemCountryCodeMatched(providerItem, countryCode) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if providerItem.Rule == method || providerItem.Rule == "" || providerItem.Rule == "All" || providerItem.Rule == "all" || providerItem.Rule == "None" {
|
||||||
if provider, ok := m[providerItem.Name]; ok {
|
if provider, ok := m[providerItem.Name]; ok {
|
||||||
return provider, nil
|
return provider, nil
|
||||||
}
|
}
|
||||||
@ -65,11 +84,11 @@ func (application *Application) GetProviderByCategoryAndRule(category string, me
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (application *Application) GetEmailProvider(method string) (*Provider, error) {
|
func (application *Application) GetEmailProvider(method string) (*Provider, error) {
|
||||||
return application.GetProviderByCategoryAndRule("Email", method)
|
return application.GetProviderByCategoryAndRule("Email", method, "All")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (application *Application) GetSmsProvider(method string) (*Provider, error) {
|
func (application *Application) GetSmsProvider(method string, countryCode string) (*Provider, error) {
|
||||||
return application.GetProviderByCategoryAndRule("SMS", method)
|
return application.GetProviderByCategoryAndRule("SMS", method, countryCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (application *Application) GetStorageProvider() (*Provider, error) {
|
func (application *Application) GetStorageProvider() (*Provider, error) {
|
||||||
|
@ -409,7 +409,7 @@ func initBuiltInPermission() {
|
|||||||
Groups: []string{},
|
Groups: []string{},
|
||||||
Roles: []string{},
|
Roles: []string{},
|
||||||
Domains: []string{},
|
Domains: []string{},
|
||||||
Model: "model-built-in",
|
Model: "user-model-built-in",
|
||||||
Adapter: "",
|
Adapter: "",
|
||||||
ResourceType: "Application",
|
ResourceType: "Application",
|
||||||
Resources: []string{"app-built-in"},
|
Resources: []string{"app-built-in"},
|
||||||
|
@ -266,7 +266,13 @@ func initDefinedOrganization(organization *Organization) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if existed != nil {
|
if existed != nil {
|
||||||
return
|
affected, err := deleteOrganization(organization)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if !affected {
|
||||||
|
panic("Fail to delete organization")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
organization.CreatedTime = util.GetCurrentTime()
|
organization.CreatedTime = util.GetCurrentTime()
|
||||||
organization.AccountItems = getBuiltInAccountItems()
|
organization.AccountItems = getBuiltInAccountItems()
|
||||||
@ -284,7 +290,13 @@ func initDefinedApplication(application *Application) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if existed != nil {
|
if existed != nil {
|
||||||
return
|
affected, err := deleteApplication(application)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if !affected {
|
||||||
|
panic("Fail to delete application")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
application.CreatedTime = util.GetCurrentTime()
|
application.CreatedTime = util.GetCurrentTime()
|
||||||
_, err = AddApplication(application)
|
_, err = AddApplication(application)
|
||||||
@ -299,7 +311,13 @@ func initDefinedUser(user *User) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if existed != nil {
|
if existed != nil {
|
||||||
return
|
affected, err := DeleteUser(user)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if !affected {
|
||||||
|
panic("Fail to delete user")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
user.CreatedTime = util.GetCurrentTime()
|
user.CreatedTime = util.GetCurrentTime()
|
||||||
user.Id = util.GenerateId()
|
user.Id = util.GenerateId()
|
||||||
@ -319,7 +337,13 @@ func initDefinedCert(cert *Cert) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if existed != nil {
|
if existed != nil {
|
||||||
return
|
affected, err := DeleteCert(cert)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if !affected {
|
||||||
|
panic("Fail to delete cert")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cert.CreatedTime = util.GetCurrentTime()
|
cert.CreatedTime = util.GetCurrentTime()
|
||||||
_, err = AddCert(cert)
|
_, err = AddCert(cert)
|
||||||
@ -335,7 +359,13 @@ func initDefinedLdap(ldap *Ldap) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if existed != nil {
|
if existed != nil {
|
||||||
return
|
affected, err := DeleteLdap(ldap)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if !affected {
|
||||||
|
panic("Fail to delete ldap")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_, err = AddLdap(ldap)
|
_, err = AddLdap(ldap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -350,7 +380,13 @@ func initDefinedProvider(provider *Provider) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if existed != nil {
|
if existed != nil {
|
||||||
return
|
affected, err := DeleteProvider(provider)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if !affected {
|
||||||
|
panic("Fail to delete provider")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_, err = AddProvider(provider)
|
_, err = AddProvider(provider)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -365,7 +401,13 @@ func initDefinedModel(model *Model) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if existed != nil {
|
if existed != nil {
|
||||||
return
|
affected, err := DeleteModel(model)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if !affected {
|
||||||
|
panic("Fail to delete provider")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
model.CreatedTime = util.GetCurrentTime()
|
model.CreatedTime = util.GetCurrentTime()
|
||||||
_, err = AddModel(model)
|
_, err = AddModel(model)
|
||||||
@ -381,7 +423,13 @@ func initDefinedPermission(permission *Permission) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if existed != nil {
|
if existed != nil {
|
||||||
return
|
affected, err := DeletePermission(permission)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if !affected {
|
||||||
|
panic("Fail to delete permission")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
permission.CreatedTime = util.GetCurrentTime()
|
permission.CreatedTime = util.GetCurrentTime()
|
||||||
_, err = AddPermission(permission)
|
_, err = AddPermission(permission)
|
||||||
@ -397,7 +445,13 @@ func initDefinedPayment(payment *Payment) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if existed != nil {
|
if existed != nil {
|
||||||
return
|
affected, err := DeletePayment(payment)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if !affected {
|
||||||
|
panic("Fail to delete payment")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
payment.CreatedTime = util.GetCurrentTime()
|
payment.CreatedTime = util.GetCurrentTime()
|
||||||
_, err = AddPayment(payment)
|
_, err = AddPayment(payment)
|
||||||
@ -413,7 +467,13 @@ func initDefinedProduct(product *Product) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if existed != nil {
|
if existed != nil {
|
||||||
return
|
affected, err := DeleteProduct(product)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if !affected {
|
||||||
|
panic("Fail to delete product")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
product.CreatedTime = util.GetCurrentTime()
|
product.CreatedTime = util.GetCurrentTime()
|
||||||
_, err = AddProduct(product)
|
_, err = AddProduct(product)
|
||||||
@ -429,7 +489,13 @@ func initDefinedResource(resource *Resource) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if existed != nil {
|
if existed != nil {
|
||||||
return
|
affected, err := DeleteResource(resource)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if !affected {
|
||||||
|
panic("Fail to delete resource")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
resource.CreatedTime = util.GetCurrentTime()
|
resource.CreatedTime = util.GetCurrentTime()
|
||||||
_, err = AddResource(resource)
|
_, err = AddResource(resource)
|
||||||
@ -445,7 +511,13 @@ func initDefinedRole(role *Role) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if existed != nil {
|
if existed != nil {
|
||||||
return
|
affected, err := DeleteRole(role)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if !affected {
|
||||||
|
panic("Fail to delete role")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
role.CreatedTime = util.GetCurrentTime()
|
role.CreatedTime = util.GetCurrentTime()
|
||||||
_, err = AddRole(role)
|
_, err = AddRole(role)
|
||||||
@ -461,7 +533,13 @@ func initDefinedSyncer(syncer *Syncer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if existed != nil {
|
if existed != nil {
|
||||||
return
|
affected, err := DeleteSyncer(syncer)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if !affected {
|
||||||
|
panic("Fail to delete role")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
syncer.CreatedTime = util.GetCurrentTime()
|
syncer.CreatedTime = util.GetCurrentTime()
|
||||||
_, err = AddSyncer(syncer)
|
_, err = AddSyncer(syncer)
|
||||||
@ -477,7 +555,13 @@ func initDefinedToken(token *Token) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if existed != nil {
|
if existed != nil {
|
||||||
return
|
affected, err := DeleteToken(token)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if !affected {
|
||||||
|
panic("Fail to delete token")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
token.CreatedTime = util.GetCurrentTime()
|
token.CreatedTime = util.GetCurrentTime()
|
||||||
_, err = AddToken(token)
|
_, err = AddToken(token)
|
||||||
@ -493,7 +577,13 @@ func initDefinedWebhook(webhook *Webhook) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if existed != nil {
|
if existed != nil {
|
||||||
return
|
affected, err := DeleteWebhook(webhook)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if !affected {
|
||||||
|
panic("Fail to delete webhook")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
webhook.CreatedTime = util.GetCurrentTime()
|
webhook.CreatedTime = util.GetCurrentTime()
|
||||||
_, err = AddWebhook(webhook)
|
_, err = AddWebhook(webhook)
|
||||||
@ -508,7 +598,13 @@ func initDefinedGroup(group *Group) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if existed != nil {
|
if existed != nil {
|
||||||
return
|
affected, err := DeleteGroup(group)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if !affected {
|
||||||
|
panic("Fail to delete group")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
group.CreatedTime = util.GetCurrentTime()
|
group.CreatedTime = util.GetCurrentTime()
|
||||||
_, err = AddGroup(group)
|
_, err = AddGroup(group)
|
||||||
@ -523,7 +619,13 @@ func initDefinedAdapter(adapter *Adapter) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if existed != nil {
|
if existed != nil {
|
||||||
return
|
affected, err := DeleteAdapter(adapter)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if !affected {
|
||||||
|
panic("Fail to delete adapter")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
adapter.CreatedTime = util.GetCurrentTime()
|
adapter.CreatedTime = util.GetCurrentTime()
|
||||||
_, err = AddAdapter(adapter)
|
_, err = AddAdapter(adapter)
|
||||||
@ -538,7 +640,13 @@ func initDefinedEnforcer(enforcer *Enforcer) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if existed != nil {
|
if existed != nil {
|
||||||
return
|
affected, err := DeleteEnforcer(enforcer)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if !affected {
|
||||||
|
panic("Fail to delete enforcer")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
enforcer.CreatedTime = util.GetCurrentTime()
|
enforcer.CreatedTime = util.GetCurrentTime()
|
||||||
_, err = AddEnforcer(enforcer)
|
_, err = AddEnforcer(enforcer)
|
||||||
@ -553,7 +661,13 @@ func initDefinedPlan(plan *Plan) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if existed != nil {
|
if existed != nil {
|
||||||
return
|
affected, err := DeletePlan(plan)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if !affected {
|
||||||
|
panic("Fail to delete enforcer")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
plan.CreatedTime = util.GetCurrentTime()
|
plan.CreatedTime = util.GetCurrentTime()
|
||||||
_, err = AddPlan(plan)
|
_, err = AddPlan(plan)
|
||||||
@ -568,7 +682,13 @@ func initDefinedPricing(pricing *Pricing) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if existed != nil {
|
if existed != nil {
|
||||||
return
|
affected, err := DeletePricing(pricing)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if !affected {
|
||||||
|
panic("Fail to delete pricing")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pricing.CreatedTime = util.GetCurrentTime()
|
pricing.CreatedTime = util.GetCurrentTime()
|
||||||
_, err = AddPricing(pricing)
|
_, err = AddPricing(pricing)
|
||||||
@ -583,7 +703,13 @@ func initDefinedInvitation(invitation *Invitation) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if existed != nil {
|
if existed != nil {
|
||||||
return
|
affected, err := DeleteInvitation(invitation)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if !affected {
|
||||||
|
panic("Fail to delete invitation")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
invitation.CreatedTime = util.GetCurrentTime()
|
invitation.CreatedTime = util.GetCurrentTime()
|
||||||
_, err = AddInvitation(invitation, "en")
|
_, err = AddInvitation(invitation, "en")
|
||||||
@ -611,7 +737,13 @@ func initDefinedSubscription(subscription *Subscription) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if existed != nil {
|
if existed != nil {
|
||||||
return
|
affected, err := DeleteSubscription(subscription)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if !affected {
|
||||||
|
panic("Fail to delete subscription")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
subscription.CreatedTime = util.GetCurrentTime()
|
subscription.CreatedTime = util.GetCurrentTime()
|
||||||
_, err = AddSubscription(subscription)
|
_, err = AddSubscription(subscription)
|
||||||
@ -626,7 +758,13 @@ func initDefinedTransaction(transaction *Transaction) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if existed != nil {
|
if existed != nil {
|
||||||
return
|
affected, err := DeleteTransaction(transaction)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if !affected {
|
||||||
|
panic("Fail to delete transaction")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
transaction.CreatedTime = util.GetCurrentTime()
|
transaction.CreatedTime = util.GetCurrentTime()
|
||||||
_, err = AddTransaction(transaction)
|
_, err = AddTransaction(transaction)
|
||||||
|
@ -241,11 +241,7 @@ func AddOrganization(organization *Organization) (bool, error) {
|
|||||||
return affected != 0, nil
|
return affected != 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteOrganization(organization *Organization) (bool, error) {
|
func deleteOrganization(organization *Organization) (bool, error) {
|
||||||
if organization.Name == "built-in" {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
affected, err := ormer.Engine.ID(core.PK{organization.Owner, organization.Name}).Delete(&Organization{})
|
affected, err := ormer.Engine.ID(core.PK{organization.Owner, organization.Name}).Delete(&Organization{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
@ -254,6 +250,14 @@ func DeleteOrganization(organization *Organization) (bool, error) {
|
|||||||
return affected != 0, nil
|
return affected != 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DeleteOrganization(organization *Organization) (bool, error) {
|
||||||
|
if organization.Name == "built-in" {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return deleteOrganization(organization)
|
||||||
|
}
|
||||||
|
|
||||||
func GetOrganizationByUser(user *User) (*Organization, error) {
|
func GetOrganizationByUser(user *User) (*Organization, error) {
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
@ -18,13 +18,14 @@ type ProviderItem struct {
|
|||||||
Owner string `json:"owner"`
|
Owner string `json:"owner"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
|
||||||
CanSignUp bool `json:"canSignUp"`
|
CanSignUp bool `json:"canSignUp"`
|
||||||
CanSignIn bool `json:"canSignIn"`
|
CanSignIn bool `json:"canSignIn"`
|
||||||
CanUnlink bool `json:"canUnlink"`
|
CanUnlink bool `json:"canUnlink"`
|
||||||
Prompted bool `json:"prompted"`
|
CountryCodes []string `json:"countryCodes"`
|
||||||
SignupGroup string `json:"signupGroup"`
|
Prompted bool `json:"prompted"`
|
||||||
Rule string `json:"rule"`
|
SignupGroup string `json:"signupGroup"`
|
||||||
Provider *Provider `json:"provider"`
|
Rule string `json:"rule"`
|
||||||
|
Provider *Provider `json:"provider"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (application *Application) GetProviderItem(providerName string) *ProviderItem {
|
func (application *Application) GetProviderItem(providerName string) *ProviderItem {
|
||||||
|
@ -17,6 +17,7 @@ package object
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/beego/beego/context"
|
"github.com/beego/beego/context"
|
||||||
@ -25,10 +26,14 @@ import (
|
|||||||
"github.com/casvisor/casvisor-go-sdk/casvisorsdk"
|
"github.com/casvisor/casvisor-go-sdk/casvisorsdk"
|
||||||
)
|
)
|
||||||
|
|
||||||
var logPostOnly bool
|
var (
|
||||||
|
logPostOnly bool
|
||||||
|
passwordRegex *regexp.Regexp
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
logPostOnly = conf.GetConfigBool("logPostOnly")
|
logPostOnly = conf.GetConfigBool("logPostOnly")
|
||||||
|
passwordRegex = regexp.MustCompile("\"password\":\".+\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
type Record struct {
|
type Record struct {
|
||||||
@ -40,6 +45,10 @@ type Response struct {
|
|||||||
Msg string `json:"msg"`
|
Msg string `json:"msg"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func maskPassword(recordString string) string {
|
||||||
|
return passwordRegex.ReplaceAllString(recordString, "\"password\":\"***\"")
|
||||||
|
}
|
||||||
|
|
||||||
func NewRecord(ctx *context.Context) (*casvisorsdk.Record, error) {
|
func NewRecord(ctx *context.Context) (*casvisorsdk.Record, error) {
|
||||||
ip := strings.Replace(util.GetIPFromRequest(ctx.Request), ": ", "", -1)
|
ip := strings.Replace(util.GetIPFromRequest(ctx.Request), ": ", "", -1)
|
||||||
action := strings.Replace(ctx.Request.URL.Path, "/api/", "", -1)
|
action := strings.Replace(ctx.Request.URL.Path, "/api/", "", -1)
|
||||||
@ -51,6 +60,7 @@ func NewRecord(ctx *context.Context) (*casvisorsdk.Record, error) {
|
|||||||
object := ""
|
object := ""
|
||||||
if ctx.Input.RequestBody != nil && len(ctx.Input.RequestBody) != 0 {
|
if ctx.Input.RequestBody != nil && len(ctx.Input.RequestBody) != 0 {
|
||||||
object = string(ctx.Input.RequestBody)
|
object = string(ctx.Input.RequestBody)
|
||||||
|
object = maskPassword(object)
|
||||||
}
|
}
|
||||||
|
|
||||||
respBytes, err := json.Marshal(ctx.Input.Data()["json"])
|
respBytes, err := json.Marshal(ctx.Input.Data()["json"])
|
||||||
@ -99,6 +109,8 @@ func AddRecord(record *casvisorsdk.Record) bool {
|
|||||||
|
|
||||||
record.Owner = record.Organization
|
record.Owner = record.Organization
|
||||||
|
|
||||||
|
record.Object = maskPassword(record.Object)
|
||||||
|
|
||||||
errWebhook := SendWebhooks(record)
|
errWebhook := SendWebhooks(record)
|
||||||
if errWebhook == nil {
|
if errWebhook == nil {
|
||||||
record.IsTriggered = true
|
record.IsTriggered = true
|
||||||
|
@ -48,7 +48,7 @@ func SendSms(provider *Provider, content string, phoneNumbers ...string) error {
|
|||||||
if provider.AppId != "" {
|
if provider.AppId != "" {
|
||||||
phoneNumbers = append([]string{provider.AppId}, phoneNumbers...)
|
phoneNumbers = append([]string{provider.AppId}, phoneNumbers...)
|
||||||
}
|
}
|
||||||
} else if provider.Type == sender.Aliyun {
|
} else if provider.Type == sender.Aliyun || provider.Type == sender.SendCloud {
|
||||||
for i, number := range phoneNumbers {
|
for i, number := range phoneNumbers {
|
||||||
phoneNumbers[i] = strings.TrimPrefix(number, "+86")
|
phoneNumbers[i] = strings.TrimPrefix(number, "+86")
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ func fastAutoSignin(ctx *context.Context) (string, error) {
|
|||||||
scope := ctx.Input.Query("scope")
|
scope := ctx.Input.Query("scope")
|
||||||
state := ctx.Input.Query("state")
|
state := ctx.Input.Query("state")
|
||||||
nonce := ""
|
nonce := ""
|
||||||
codeChallenge := ""
|
codeChallenge := ctx.Input.Query("code_challenge")
|
||||||
if clientId == "" || responseType != "code" || redirectUri == "" {
|
if clientId == "" || responseType != "code" || redirectUri == "" {
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ class ProductEditPage extends React.Component {
|
|||||||
UNSAFE_componentWillMount() {
|
UNSAFE_componentWillMount() {
|
||||||
this.getProduct();
|
this.getProduct();
|
||||||
this.getOrganizations();
|
this.getOrganizations();
|
||||||
this.getPaymentProviders();
|
this.getPaymentProviders(this.state.organizationName);
|
||||||
}
|
}
|
||||||
|
|
||||||
getProduct() {
|
getProduct() {
|
||||||
@ -67,8 +67,8 @@ class ProductEditPage extends React.Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getPaymentProviders() {
|
getPaymentProviders(organizationName) {
|
||||||
ProviderBackend.getProviders(this.props.account.owner)
|
ProviderBackend.getProviders(organizationName)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.status === "ok") {
|
if (res.status === "ok") {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -209,6 +209,8 @@ class ProviderEditPage extends React.Component {
|
|||||||
return Setting.getLabel(i18next.t("provider:Public key"), i18next.t("provider:Public key - Tooltip"));
|
return Setting.getLabel(i18next.t("provider:Public key"), i18next.t("provider:Public key - Tooltip"));
|
||||||
} else if (provider.type === "Msg91 SMS" || provider.type === "Infobip SMS" || provider.type === "OSON SMS") {
|
} else if (provider.type === "Msg91 SMS" || provider.type === "Infobip SMS" || provider.type === "OSON SMS") {
|
||||||
return Setting.getLabel(i18next.t("provider:Sender Id"), i18next.t("provider:Sender Id - Tooltip"));
|
return Setting.getLabel(i18next.t("provider:Sender Id"), i18next.t("provider:Sender Id - Tooltip"));
|
||||||
|
} else if (provider.type === "SendCloud SMS") {
|
||||||
|
return "SMS_USER";
|
||||||
} else {
|
} else {
|
||||||
return Setting.getLabel(i18next.t("provider:Client ID"), i18next.t("provider:Client ID - Tooltip"));
|
return Setting.getLabel(i18next.t("provider:Client ID"), i18next.t("provider:Client ID - Tooltip"));
|
||||||
}
|
}
|
||||||
@ -260,6 +262,8 @@ class ProviderEditPage extends React.Component {
|
|||||||
return Setting.getLabel(i18next.t("provider:Auth Key"), i18next.t("provider:Auth Key - Tooltip"));
|
return Setting.getLabel(i18next.t("provider:Auth Key"), i18next.t("provider:Auth Key - Tooltip"));
|
||||||
} else if (provider.type === "Infobip SMS") {
|
} else if (provider.type === "Infobip SMS") {
|
||||||
return Setting.getLabel(i18next.t("provider:Api Key"), i18next.t("provider:Api Key - Tooltip"));
|
return Setting.getLabel(i18next.t("provider:Api Key"), i18next.t("provider:Api Key - Tooltip"));
|
||||||
|
} else if (provider.type === "SendCloud SMS") {
|
||||||
|
return "SMS_KEY";
|
||||||
} else {
|
} else {
|
||||||
return Setting.getLabel(i18next.t("provider:Client secret"), i18next.t("provider:Client secret - Tooltip"));
|
return Setting.getLabel(i18next.t("provider:Client secret"), i18next.t("provider:Client secret - Tooltip"));
|
||||||
}
|
}
|
||||||
@ -1089,7 +1093,7 @@ class ProviderEditPage extends React.Component {
|
|||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
) : this.state.provider.category === "SMS" ? (
|
) : this.state.provider.category === "SMS" ? (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
{["Custom HTTP SMS", "Twilio SMS", "Amazon SNS", "Azure ACS", "Msg91 SMS", "Infobip SMS"].includes(this.state.provider.type) ?
|
{["Custom HTTP SMS", "Twilio SMS", "Amazon SNS", "Azure ACS", "Msg91 SMS", "Infobip SMS", "SendCloud SMS"].includes(this.state.provider.type) ?
|
||||||
null :
|
null :
|
||||||
(<Row style={{marginTop: "20px"}} >
|
(<Row style={{marginTop: "20px"}} >
|
||||||
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
||||||
|
@ -139,6 +139,10 @@ export const OtherProviderInfo = {
|
|||||||
logo: `${StaticBaseUrl}/img/social_twilio.svg`,
|
logo: `${StaticBaseUrl}/img/social_twilio.svg`,
|
||||||
url: "https://www.twilio.com/messaging",
|
url: "https://www.twilio.com/messaging",
|
||||||
},
|
},
|
||||||
|
"SendCloud SMS": {
|
||||||
|
logo: `${StaticBaseUrl}/img/sms_sendcloud.png`,
|
||||||
|
url: "https://www.sendcloud.net/",
|
||||||
|
},
|
||||||
"SmsBao SMS": {
|
"SmsBao SMS": {
|
||||||
logo: `${StaticBaseUrl}/img/social_smsbao.png`,
|
logo: `${StaticBaseUrl}/img/social_smsbao.png`,
|
||||||
url: "https://www.smsbao.com/",
|
url: "https://www.smsbao.com/",
|
||||||
@ -1039,6 +1043,7 @@ export function getProviderTypeOptions(category) {
|
|||||||
{id: "Huawei Cloud SMS", name: "Huawei Cloud SMS"},
|
{id: "Huawei Cloud SMS", name: "Huawei Cloud SMS"},
|
||||||
{id: "UCloud SMS", name: "UCloud SMS"},
|
{id: "UCloud SMS", name: "UCloud SMS"},
|
||||||
{id: "Twilio SMS", name: "Twilio SMS"},
|
{id: "Twilio SMS", name: "Twilio SMS"},
|
||||||
|
{id: "SendCloud SMS", name: "SendCloud SMS"},
|
||||||
{id: "SmsBao SMS", name: "SmsBao SMS"},
|
{id: "SmsBao SMS", name: "SmsBao SMS"},
|
||||||
{id: "SUBMAIL SMS", name: "SUBMAIL SMS"},
|
{id: "SUBMAIL SMS", name: "SUBMAIL SMS"},
|
||||||
{id: "Msg91 SMS", name: "Msg91 SMS"},
|
{id: "Msg91 SMS", name: "Msg91 SMS"},
|
||||||
|
@ -840,7 +840,7 @@ class LoginPage extends React.Component {
|
|||||||
{application.displayName}
|
{application.displayName}
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
:
|
:
|
||||||
</div>
|
</div>
|
||||||
<br />
|
<br />
|
||||||
{
|
{
|
||||||
|
@ -172,23 +172,23 @@ export function renderProviderLogo(provider, application, width, margin, size, l
|
|||||||
const customAStyle = {display: "block", height: "55px", color: "#000"};
|
const customAStyle = {display: "block", height: "55px", color: "#000"};
|
||||||
const customButtonStyle = {display: "flex", alignItems: "center", width: "calc(100% - 10px)", height: "50px", margin: "5px", padding: "0 10px", backgroundColor: "transparent", boxShadow: "0px 1px 3px rgba(0,0,0,0.5)", border: "0px", borderRadius: "3px", cursor: "pointer"};
|
const customButtonStyle = {display: "flex", alignItems: "center", width: "calc(100% - 10px)", height: "50px", margin: "5px", padding: "0 10px", backgroundColor: "transparent", boxShadow: "0px 1px 3px rgba(0,0,0,0.5)", border: "0px", borderRadius: "3px", cursor: "pointer"};
|
||||||
const customImgStyle = {justfyContent: "space-between"};
|
const customImgStyle = {justfyContent: "space-between"};
|
||||||
const customSpanStyle = {textAlign: "center", lineHeight: "50px", width: "100%", fontSize: "19px"};
|
const customSpanStyle = {textAlign: "center", width: "100%", fontSize: "19px"};
|
||||||
if (provider.category === "OAuth") {
|
if (provider.category === "OAuth") {
|
||||||
return (
|
return (
|
||||||
<a key={provider.displayName} href={Provider.getAuthUrl(application, provider, "signup")} style={customAStyle}>
|
<a key={provider.displayName} href={Provider.getAuthUrl(application, provider, "signup")} style={customAStyle}>
|
||||||
<button style={customButtonStyle}>
|
<div style={customButtonStyle}>
|
||||||
<img width={26} src={getProviderLogoURL(provider)} alt={provider.displayName} className="provider-img" style={customImgStyle} />
|
<img width={26} src={getProviderLogoURL(provider)} alt={provider.displayName} className="provider-img" style={customImgStyle} />
|
||||||
<span style={customSpanStyle}>{text}</span>
|
<span style={customSpanStyle}>{text}</span>
|
||||||
</button>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
);
|
);
|
||||||
} else if (provider.category === "SAML") {
|
} else if (provider.category === "SAML") {
|
||||||
return (
|
return (
|
||||||
<a key={provider.displayName} onClick={() => goToSamlUrl(provider, location)} style={customAStyle}>
|
<a key={provider.displayName} onClick={() => goToSamlUrl(provider, location)} style={customAStyle}>
|
||||||
<button style={customButtonStyle}>
|
<div style={customButtonStyle}>
|
||||||
<img width={26} src={getProviderLogoURL(provider)} alt={provider.displayName} className="provider-img" style={customImgStyle} />
|
<img width={26} src={getProviderLogoURL(provider)} alt={provider.displayName} className="provider-img" style={customImgStyle} />
|
||||||
<span style={customSpanStyle}>{text}</span>
|
<span style={customSpanStyle}>{text}</span>
|
||||||
</button>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,14 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import {Select} from "antd";
|
import {Select} from "antd";
|
||||||
|
import i18next from "i18next";
|
||||||
import * as Setting from "../../Setting";
|
import * as Setting from "../../Setting";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
|
const {Option} = Select;
|
||||||
|
|
||||||
export const CountryCodeSelect = (props) => {
|
export const CountryCodeSelect = (props) => {
|
||||||
const {onChange, style, disabled, initValue} = props;
|
const {onChange, style, disabled, initValue, mode} = props;
|
||||||
const countryCodes = props.countryCodes ?? [];
|
const countryCodes = props.countryCodes ?? [];
|
||||||
const [value, setValue] = React.useState("");
|
const [value, setValue] = React.useState("");
|
||||||
|
|
||||||
@ -42,11 +45,19 @@ export const CountryCodeSelect = (props) => {
|
|||||||
style={style}
|
style={style}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
value={value}
|
value={value}
|
||||||
|
mode={mode}
|
||||||
dropdownMatchSelectWidth={false}
|
dropdownMatchSelectWidth={false}
|
||||||
optionLabelProp={"label"}
|
optionLabelProp={"label"}
|
||||||
onChange={handleOnChange}
|
onChange={handleOnChange}
|
||||||
filterOption={(input, option) => (option?.text ?? "").toLowerCase().includes(input.toLowerCase())}
|
filterOption={(input, option) => (option?.text ?? "").toLowerCase().includes(input.toLowerCase())}
|
||||||
>
|
>
|
||||||
|
{
|
||||||
|
props.hasDefault ? (<Option key={"All"} value={"All"} label={i18next.t("organization:All")} text={"organization:All"} >
|
||||||
|
<div style={{display: "flex", justifyContent: "space-between", marginRight: "10px"}}>
|
||||||
|
{i18next.t("organization:All")}
|
||||||
|
</div>
|
||||||
|
</Option>) : null
|
||||||
|
}
|
||||||
{
|
{
|
||||||
Setting.getCountryCodeData(countryCodes).map((country) => Setting.getCountryCodeOption(country))
|
Setting.getCountryCodeData(countryCodes).map((country) => Setting.getCountryCodeOption(country))
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import {DeleteOutlined, DownOutlined, UpOutlined} from "@ant-design/icons";
|
import {DeleteOutlined, DownOutlined, UpOutlined} from "@ant-design/icons";
|
||||||
import {Button, Col, Input, Row, Select, Switch, Table, Tooltip} from "antd";
|
import {Button, Col, Input, Row, Select, Switch, Table, Tooltip} from "antd";
|
||||||
|
import {CountryCodeSelect} from "../common/select/CountryCodeSelect";
|
||||||
import * as Setting from "../Setting";
|
import * as Setting from "../Setting";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
import * as Provider from "../auth/Provider";
|
import * as Provider from "../auth/Provider";
|
||||||
@ -29,6 +30,10 @@ class ProviderTable extends React.Component {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getUserOrganization() {
|
||||||
|
return this.props.application?.organizationObj;
|
||||||
|
}
|
||||||
|
|
||||||
updateTable(table) {
|
updateTable(table) {
|
||||||
this.props.onUpdateTable(table);
|
this.props.onUpdateTable(table);
|
||||||
}
|
}
|
||||||
@ -79,7 +84,7 @@ class ProviderTable extends React.Component {
|
|||||||
|
|
||||||
// If the provider is email or SMS, set the rule to "all" instead of the default "None"
|
// If the provider is email or SMS, set the rule to "all" instead of the default "None"
|
||||||
if (provider.category === "Email" || provider.category === "SMS") {
|
if (provider.category === "Email" || provider.category === "SMS") {
|
||||||
this.updateField(table, index, "rule", "all");
|
this.updateField(table, index, "rule", "All");
|
||||||
}
|
}
|
||||||
}} >
|
}} >
|
||||||
{
|
{
|
||||||
@ -109,6 +114,30 @@ class ProviderTable extends React.Component {
|
|||||||
return Provider.getProviderLogoWidget(provider);
|
return Provider.getProviderLogoWidget(provider);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: i18next.t("user:Country/Region"),
|
||||||
|
dataIndex: "countryCodes",
|
||||||
|
key: "countryCodes",
|
||||||
|
width: "140px",
|
||||||
|
render: (text, record, index) => {
|
||||||
|
if (record.provider?.category !== "SMS") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<CountryCodeSelect
|
||||||
|
style={{width: "100%"}}
|
||||||
|
hasDefault={true}
|
||||||
|
mode={"multiple"}
|
||||||
|
initValue={text ? text : ["All"]}
|
||||||
|
onChange={(value) => {
|
||||||
|
this.updateField(table, index, "countryCodes", value);
|
||||||
|
}}
|
||||||
|
countryCodes={this.getUserOrganization()?.countryCodes}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: i18next.t("provider:Can signup"),
|
title: i18next.t("provider:Can signup"),
|
||||||
dataIndex: "canSignUp",
|
dataIndex: "canSignUp",
|
||||||
@ -198,7 +227,7 @@ class ProviderTable extends React.Component {
|
|||||||
title: i18next.t("application:Rule"),
|
title: i18next.t("application:Rule"),
|
||||||
dataIndex: "rule",
|
dataIndex: "rule",
|
||||||
key: "rule",
|
key: "rule",
|
||||||
width: "120px",
|
width: "160px",
|
||||||
render: (text, record, index) => {
|
render: (text, record, index) => {
|
||||||
if (record.provider?.type === "Google") {
|
if (record.provider?.type === "Google") {
|
||||||
if (text === "None") {
|
if (text === "None") {
|
||||||
@ -230,12 +259,12 @@ class ProviderTable extends React.Component {
|
|||||||
);
|
);
|
||||||
} else if (record.provider?.category === "SMS" || record.provider?.category === "Email") {
|
} else if (record.provider?.category === "SMS" || record.provider?.category === "Email") {
|
||||||
if (text === "None") {
|
if (text === "None") {
|
||||||
text = "all";
|
text = "All";
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<Select virtual={false} style={{width: "100%"}}
|
<Select virtual={false} style={{width: "100%"}}
|
||||||
value={text}
|
value={text}
|
||||||
defaultValue="all"
|
defaultValue="All"
|
||||||
onChange={value => {
|
onChange={value => {
|
||||||
this.updateField(table, index, "rule", value);
|
this.updateField(table, index, "rule", value);
|
||||||
}}>
|
}}>
|
||||||
|
@ -164,7 +164,7 @@ class SigninMethodTable extends React.Component {
|
|||||||
<Button style={{marginRight: "5px"}} disabled={index === table.length - 1} icon={<DownOutlined />} size="small" onClick={() => this.downRow(table, index)} />
|
<Button style={{marginRight: "5px"}} disabled={index === table.length - 1} icon={<DownOutlined />} size="small" onClick={() => this.downRow(table, index)} />
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip placement="topLeft" title={i18next.t("general:Delete")}>
|
<Tooltip placement="topLeft" title={i18next.t("general:Delete")}>
|
||||||
<Button icon={<DeleteOutlined />} size="small" onClick={() => this.deleteRow(items, table, index)} />
|
<Button disabled={table.length <= 1} icon={<DeleteOutlined />} size="small" onClick={() => this.deleteRow(items, table, index)} />
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user