How To Debug

This article describes how to use the Authing console to debug Pipeline functions.

In the previous step, we have created the first Pipeline function (opens new window), and at the same time review the function code as:

async function pipe(context, callback) {
  const email = context.data.userInfo.email;
  // 非邮箱注册方式
  if (!email) {
    return callback(null, context);
  }
  if (!email.endsWith("example.com")) {
    return callback(new Error("Access denied."));
  }
  return callback(null, context);
}

The function of the Pipeline function is to only allow the example.com (opens new window)registration of mailboxes with thedomain name suffix.

Click the debug button of the Pipeline function:

Click this button to open the debugging window: Authing will produce corresponding test data based on your user pool.

Notes that the data.userInfo.emailis** xxxxxx@example.com **.

Click the "Debug" button: the debug result is output below, and we get the latest context object, indicating that this mailbox has passed the Pipeline function.

We then changed the email suffix to qq.com, and we got the corresponding error message in the output area.

View logs

Need to use global Authing Pipeline built-in functionlogto view the running log, notconsole.log!

Use the function editor to modify the code and add a line at the beginning of the function: Note that it is log instead of console.log.

Plain%20Textlog(context);

Click "Debug" again to see the output log.

If there is no log output, please try again!

Catch syntax errors

If your function has a syntax error, Authing Pipeline can also catch it. Here we modify the code and add a line of xxxxxxx at the beginning of the pipe function:

Click again debugging, you can see the corresponding error message:message: "xxxxxxx is not defined".

We recommend using a debugger to debug the code first, and then post the function online.

Logo

Authing 是一款以开发者为中心的全场景身份云产品,集成了所有主流身份认证协议,为企业和开发者提供完善安全的用户认证和访问管理服务

更多推荐