Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't submit the SMS provider settings form without empty provider but can't set Twilio until I submit the form #17057

Open
barthamark opened this issue Nov 25, 2024 · 1 comment
Labels

Comments

@barthamark
Copy link
Contributor

Describe the bug

After enabling the SMS Notifications feature I wanted to set Twilio as the default provider. For that, first, I needed to enable it on the same form where the default provider is needed to be set. However, I can't save it without selecting any provider. It can be worked around if there an option selected until I save the form and Twilio is enabled, then select Twilio, however, if there's nothing in there (e.g., in production), then there is no way to save the form. Locally, the "Log" is an option, but in prod, there's nothing in the list.

Orchard Core version

2.0.2

To Reproduce

  1. Enable "SMS Notifications"
  2. Go to Configuration > Settings > SMS
  3. Notice that Twilio is no in the Default Provider list, and nothing is selected.
  4. Go to Twilio tab.
  5. Enable Twilio and fill the form.
  6. Click Save.
  7. See validation error that Default Provider is not selected.

Expected behavior

Maybe the Default Provider shouldn't be a mandatory field? Or some JS code that adds Twilio to the list right after checking the Enable Twilio checkbox?

Workaround

  • If there is at least one other item in the Default Provider list, then select that. After enabling Twilio, replace it with that.
  • If there is no other, then create a temporary one from code like this, and do the same as above:
public class DummySmsProvider : ISmsProvider
{
    private readonly IStringLocalizer<DummySmsProvider> T;

    public LocalizedString Name => T["Dummy SMS Provider"];

    public DummySmsProvider(IStringLocalizer<DummySmsProvider> localizer) => T = localizer;

    public Task<SmsResult> SendAsync(SmsMessage message) => throw new System.NotImplementedException();
}

services.AddSmsProvider<DummySmsProvider>(nameof(DummySmsProvider));
@hishamco
Copy link
Member

There's a 'LogSmsProvider OOB, that could be used or set Twillio by default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants