An open API service indexing awesome lists of open source software.

https://github.com/modxcms/twilio

MODX Extra for Twilio Validation or something like that
https://github.com/modxcms/twilio

Last synced: 6 months ago
JSON representation

MODX Extra for Twilio Validation or something like that

Awesome Lists containing this project

README

          

# Twilio Verify

Twilio is a verification service that allows you to send a code to a user's phone or use a time-based one time password to verify their identity. You can find more information on Twilio at [https://www.twilio.com/](https://www.twilio.com/referral/BSq3ra). This is not a free service, so you will need to sign up for a Twilio account. Each successful verification will cost you $0.05, so this is something to consider before implementing.

## Phone Verification

### Sample Registration page

```html

[[!Register?
&postHooks=`TwilioActivation`
&submitVar=`registerbtn`
&moderate=`1`
&customValidators=`TwilioValidatePhone`
&twilioActivationResourceId=`2`
&twilioActivationEmailTpl=`myActivationEmailTpl`
&usernameField=`email`
&validate=`nospam:blank,
phone:TwilioValidatePhone,
password:required:minLength=^6^,
password_confirm:password_confirm=^password^,
email:required:email`
&placeholderPrefix=`reg.`
]]


[[!+reg.error.message]]


Email
[[!+reg.error.email]]

Phone
[[!+reg.error.phone]]



Password
[[!+reg.error.password]]

Confirm Password
[[!+reg.error.password_confirm]]





var phoneInputField = document.querySelector("#phone");
window.intlTelInput(phoneInputField, {
hiddenInput: "phone",
utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js",
});

```

### Sample Activation Page (&twilioActivationResourceId)

```html
[[!TwilioGetPhone]]

[[!FormIt?
&hooks=`TwilioSendVerification`
&submitVar=`get-validation`
&validate=`channel:required`
]]

Phone: [[!+twilio.phone]]

Channel: [[!+fi.error.channel]]
SMS
Call



[[!+twilio.code_sent]]

[[!FormIt?
&hooks=`TwilioVerify`
&twilioRedirect=`4`
&placeholderPrefix=`fiv.`
&submitVar=`verify`
&validate=`code:required`
]]


Code:
[[!+fiv.error.code]]




```

## Time-based One Time Password

### Sample Challenge Page

Create a challenge page and set the system setting `twilio.totp_challenge_page` to the page ID.

```html
[[!FormIt?
&hooks=`TwilioTOTPChallenge,TwilioVerify`
&twilioRedirect=`4` // ID of the page to redirect to after verification
&twilioFactorType=`totp`
&validate=`code:required`
]]


Enter 2FA Code


Submit

```

### Sample Create/Reset Token Page

Create a page with the following content:

```html
[[TwilioTOTPCreate?twilioRedirect=`4`]]
```

### Sample Profile Page

```html
[[!TwilioTOTPqr]]

[[!+twilio.qr:ne=``:then=`

Secret [[!+twilio.secret]]


[[!+twilio.status:is=`unverified`:then=`

Verify 2FA Code Before Next Login


`:else=``]]

Refresh 2FA

Disable 2FA


`:else=`
Enable 2FA
`]]
```

## System Settings

| key | description |
|----------------------------|-----------------------------------------------------------------------------------------------------------|
| twilio.account_sid | Twilio Account SID - Found under Account Info here https://console.twilio.com/ |
| twilio.account_token | Twilio Auth Token - Found under Account Info here https://console.twilio.com/ |
| twilio.service_id | Twilio Service ID - Found under Services Page here https://console.twilio.com/us1/develop/verify/services |
| twilio.totp_enforce | Enforce 2FA for all users |
| twilio.totp_email_on_login | Email a code to the user when they login |
| twilio.totp_challenge_page | Page ID of the challenge page |
| twilio.totp_allow_expired | Allow expired two-factor verification codes to regenerate new two-factor authentication codes. |

## Manager Page

Twilio 2FA Verification can be enabled in the manager login as well. You can view the status of Twilio 2FA for each user in the menu under
"Extras -> User Authentication"