在PreTokenGeneration函数中,将需要的数据转换为正确的类型,而不是默认的字符串类型。例如,将整数转换为整数,将布尔值转换为布尔值,等等。
示例代码:
exports.handler = async (event, context, callback) => { // Get the user's email from the event object const email = event.request.userAttributes.email;
// Convert the string to a number
const age = parseInt(event.request.userAttributes.age);
// Convert the string to a boolean
const isAdmin = event.request.userAttributes.isAdmin === 'true';
// Do the necessary logic and return the updated token
// ...
callback(null, event);
};