mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 04:10:20 +08:00
feat: support multiple SMS providers for different regions (#2914)
* feat: support using different sms provider for different region * feat: add multiple support for select and remove log * feat: revert change for countryCode in loginPage * feat: revert change for countryCode in user_util.go * feat: revert change for countryCode in auth.go * Update application_item.go * Update CountryCodeSelect.js * Update ProviderTable.js --------- Co-authored-by: Yang Luo <hsluoyz@qq.com>
This commit is contained in:
@ -38,7 +38,7 @@ func (application *Application) GetProviderByCategory(category string) (*Provide
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (application *Application) GetProviderByCategoryAndRule(category string, method string) (*Provider, error) {
|
||||
func (application *Application) GetProviderByCategoryAndRule(category string, method string, countryCode string) (*Provider, error) {
|
||||
providers, err := GetProviders(application.Organization)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -54,7 +54,15 @@ func (application *Application) GetProviderByCategoryAndRule(category string, me
|
||||
}
|
||||
|
||||
for _, providerItem := range application.Providers {
|
||||
if providerItem.Rule == method || (providerItem.Rule == "all" || providerItem.Rule == "" || providerItem.Rule == "None") {
|
||||
includeCode := false
|
||||
if providerItem.CountryCode != nil {
|
||||
for _, item := range providerItem.CountryCode {
|
||||
if item == countryCode || item == "All" || item == "" {
|
||||
includeCode = true
|
||||
}
|
||||
}
|
||||
}
|
||||
if (providerItem.Rule == method || (providerItem.Rule == "All" || providerItem.Rule == "" || providerItem.Rule == "None")) && includeCode {
|
||||
if provider, ok := m[providerItem.Name]; ok {
|
||||
return provider, nil
|
||||
}
|
||||
@ -65,11 +73,11 @@ func (application *Application) GetProviderByCategoryAndRule(category string, me
|
||||
}
|
||||
|
||||
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) {
|
||||
return application.GetProviderByCategoryAndRule("SMS", method)
|
||||
func (application *Application) GetSmsProvider(method string, countryCode string) (*Provider, error) {
|
||||
return application.GetProviderByCategoryAndRule("SMS", method, countryCode)
|
||||
}
|
||||
|
||||
func (application *Application) GetStorageProvider() (*Provider, error) {
|
||||
|
Reference in New Issue
Block a user