Add support for user phone number, SMS support and two-factor authentication using SMS service - This week in Orchard (25/08/2023)

Gábor Domonkos's avatar
Admin UI, This week in Orchard, Theme, Workflows

Add support for user phone number; add styling to Pager in TheAdmin theme, and a demo about SMS support and two-factor authentication using SMS service! Check out our post for the details!

Orchard Core updates

Add support for user phone number

Currently, we do not support PhoneNumber in the UserStore, which is supported in the default identity implementation, and it's a nice feature to have if you are implementing an application that requires the user to enter and confirm their cell phone number, similar to the way email verification works. The latter is easy since UserStore implements IUserEmailStore, but when using UserManager.GenerateChangePhoneNumberTokenAsync, the call fails with a NotSupportedException: Store does not implement IUserPhoneNumberStore<TUser> exception. From now on, UserStore implements IUserPhoneNumberStore, updating User accordingly by adding a Phone property. This means a phone number is now supported in the UserStore and the User object. Let's see what the new field looks like in the user's profile!

If you navigate to Security -> Users and hit the Add User button, you will find the new Phone Number field there. You may notice a black exclamation icon at the end of the editor, meaning that the phone number for this user is unverified.

The new Phone Number field

Add styling to Pager in TheAdmin theme

This change is about improving the look and feel of the Pager across the admin UI. New views in TheAdmin theme were added to style the pages at the theme level, no base shapes were altered. The pager looked like this:

The old pager

And after this change, it looks like this:

The new pager

Demos

SMS support and two-factor authentication using SMS service

In this demo, you can see a brand-new feature for Orchard Core, the SMS module. This module provides you with a way to have SMS services on your site, and then you can do whatever you want with them. There are actually three features around it, and we will check out all.

  • SMS: Provides settings and services to send SMS messages.
  • Two-Factor SMS Method: Provides users a two-factor authentication method through an SMS service.
  • SMS Notifications: Provides a way to send SMS notifications to users.

Let's enable all of them, and after that, you will find a new option under Configuration -> Settings, called SMS. Here you can configure your provider. You can choose from Log and Twilio. If you select the Log one, any message that is sent through the SMS provider will be just printed in the log files, like: "A message with the body {body} was set to {phoneNumber}".

You can implement your own provider, but by default, we provide you with Twilio. Twilio is probably the most commonly used service. If you select it, you can configure it with the information that is coming from your Twilio account.

Twilio SMS provider settings

So, this is the SMS module, and to build more on top of it, here comes the Two-Factor SMS Method feature. If you enable it, you can navigate to the Security settings, and add the new SMS authentication as a new two-factor authentication method. To do that, you have to verify your phone number, and you will get a verification code that you have to apply.

SMS authentication two-factor authentication method

The third feature is called SMS Notifications. With this module, you can actually deliver notifications through SMS. If you enable this and you can go to your user profile (Security -> Users), you will see another notification method here which is called SMS Notifications.

SMS Notifications Notification method

And if you have the Workflows feature enabled, you can utilize a new task, called Send SMS, meaning you can send SMS messages directly from the workflow.

SMS Task settings

If you want to know more about this feature, head to YouTube for a recording!

News from the community

Orchard Dojo Newsletter

Lombiq's Orchard Dojo Newsletter has 520 subscribers! We have started this newsletter to inform the community around Orchard of the latest news about the platform. By subscribing to this newsletter, you will get an e-mail whenever a new post is published to Orchard Dojo, including This week in Orchard of course.

Do you know of other Orchard enthusiasts who would like to read our weekly articles? Tell them to subscribe here!

If you are interested in more news about Orchard and the details of the topics above, don't forget to check out the recording of this Orchard meeting!

No Comments

Add a Comment