Characteristic
CabloyJS has built-in SMS Verification
module a-authsms
. It mainly has the following characteristics:
- A general mechanism of
SMS Verification
, fast connection with various SMS service providers - Realize the functions of
user registration
,user signin
anduser verification
, etc. - Built-in SMS service providers:
test
: Development and debugging can be carried out without opening the actual SMS servicealiyun
: Just fill in the parameters to quickly connect and deployaliyun
SMS service- Continue to increase support for third-party services
Screenshots
1. Sign Up
2. Sign In
3. Kitchen-sink - SMS Verification
4. Kitchen-sink - Test SMS service provider
How to use
1. Configure
By default, the SMS verification provided by the module will be enabled automatically. You can adjust the order or disable it through the following ways:
1.1 Adjust the order
For example, we now have two user authentication methods: a-authsimple/a-authsms
. The display effect is as follows:
If we want a-authsms
to display first, we only need to modify the configuration file:
src/backend/config/config.local.js
// module config
config.modules = {
...
'a-login': {
providers: [
{
module: 'a-authsms',
provider: 'authsms',
},
{
module: 'a-authsimple',
provider: 'authsimple',
},
],
},
...
};
1.2 Disable
If we want to disable a-authsimple
, just set disable: true
, as follows:
// module config
config.modules = {
...
'a-login': {
providers: [
{
module: 'a-authsms',
provider: 'authsms',
},
{
disable: true,
module: 'a-authsimple',
provider: 'authsimple',
},
],
},
...
};
The final display effect is as follows:
2. Configure SMS service provider
2.1 test
By default, the built-in test SMS service provider
is used. When the user enters the phone number
and clicks the send code
button, a random code will be automatically printed on the console to facilitate development and debugging. The effect is as follows:
2.2 aliyun
The module also has a built-in aliyun SMS service provider
, which can be activated only by modifying the configuration file:
// module config
config.modules = {
...
'a-authsms': {
sms: {
provider: {
// default: '',
default: 'aliyun',
},
providers: {
aliyun: {
accessKeyId: 'LTAIVnmixsvYC4cdF',
secretAccessKey: 'V5F7Ke7w8QgZVpcvbYcHq32FKwt2ew',
endpoint: 'https://dysmsapi.aliyuncs.com',
apiVersion: '2017-05-25',
signName: 'CabloyStore',
templates: {
mobileVerify: 'SMS_152015055',
signup: 'SMS_152015055',
signin: 'SMS_152015055',
},
},
},
},
},
};
...
signName
andtemplates
are parameters related toaliyun
SMS service provider. Please refer to aliyun’s prompts for specific data
mobileVerify
,signup
andsignin
are the predefined scenes. You can specify separate message templates for different scenarios
Comments: