更新时间:2023-02-19 17:33:28
Auth0 Lock 不会触发用户注册的特定事件.
The Auth0 Lock does not trigger a specific event for user signup.
但是,您可以在自定义规则 上检测到这一点,并使用此元数据丰富用户配置文件.有一个注册示例规则说明了这种可能性
You can however detect this on a custom rule and enrich the user profile with this metadata. There's a signup sample rule that illustrates this possibility
function (user, context, callback) {
user.app_metadata = user.app_metadata || {};
// short-circuit if the user signed up already
if (user.app_metadata.signed_up) return callback(null, user, context);
// execute first time login/signup logic here
// ...
// update application metadata so that signup logic is skipped on subsequent logins
user.app_metadata.signed_up = true;
auth0.users.updateAppMetadata(user.user_id, user.app_metadata)
.then(function () {
callback(null, user, context);
})
.catch(function (err) {
callback(err);
});
}
这使用 app_metadata
来存储与用户关联的信息,以便您可以跟踪已执行其附加首次注册逻辑的用户.
This uses app_metadata
to store information associated to the user so that you can keep track for which users you already executed their additional first-time signup logic.
请记住,规则将在身份验证管道的服务器端执行,因此如果您要实现的逻辑需要用户交互,您可以通过执行以下步骤来实现类似的效果:
Have in mind that rules will execute on the server-side of the authentication pipeline, so if the logic you want to implement requires user interaction you could achieve something similar by doing these set of steps:
app_metadata
以设置注册标志(您可以通过 Auth0 管理 API)app_metadata
to set a signup flag (you can do this on your server-side application logic through Auth0 Management API)