## 用户的角色转换 用户在注册前后经历如下角色转换 |状态|角色| |--|--| |注册前|anonymous| |注册后|registered| |激活后|activated| > 这些角色转换是自动完成的。如果禁用了`用户激活`功能,那么当注册后就会自动转换为`activated`(跨过`registered`) > 最佳实践:通过给角色`anonymous`、`registered`、`activated`赋予不同的授权,就可以精确控制用户在注册的不同阶段访问不同的功能 ## 激活方式 用户可通过`mobile`或`email`两种方式来激活。 目前CabloyJS提供了两个核心模块用于激活: |名称|说明| |--|--| |a-authsimple|`email`激活| |a-authsms|`mobile`激活| ## 激活定制 CabloyJS通过模块`a-base`提供了通用的开发接口,支持不同的用户认证模块提供自己的激活实现方式 `a-base-sync/backend/src/config/config.js` ``` javascript // account config.account = { needActivation: true, activationWays: 'mobile,email', activationProviders: { mobile: 'a-authsms', email: 'a-authsimple', }, // default is 'activated', if need activating by mobile/email, then add to 'registered' first activatedRoles: 'activated', }; ``` |名称|说明| |--|--| |needActivation|是否需要`激活`,如果不需要激活功能,就将此参数设为`false`| |activationWays|系统提供的激活方式,如果不需要`mobile`激活方式,就删掉`mobile`即可| |activationProviders|激活服务的提供者| |activatedRoles|当用户激活后,自动转入的角色名称,默认为`activated`。支持多个角色 |