Auth0 Home Blog Docs

Rules app_metadata passwordless universal is empty

auth0

#1

I defined a hosted page that has this lock definition :

var lock = new Auth0LockPasswordless(config.clientID, config.auth0Domain, {
auth: {
redirectUrl: config.callbackURL,
responseType: “token id_token”,
params: config.internalOptions,
audience: ‘http://myapp.com/crud’,
params: {
scope: ‘openid email profile picture app_metadata user_metadata’
},

  },
  assetsUrl:  config.assetsUrl,
    allowedConnections: ['email'],
  rememberLastLogin: !prompt,
  language: language,
  languageDictionary: languageDictionary,
  theme: {
    //logo:            'YOUR LOGO HERE',
    //primaryColor:    'green'
  },
  closable: false,
  // uncomment if you want small buttons for social providers
  // socialButtonStyle: 'small'
});

lock.show();

I tried to define a rule and use a app_metadata but it is empty though it is defined

function (user, context, callback) {
const namespace = ‘https://myapp.com/’;
console.log("app_metadata: " +user.app_metadata);
console.log("user: " +user);
console.log(“finished logging input”);

var role = [];
if(user.app_metadata.hasOwnProperty(‘role’)){
role =user.app_metadata.role;
}

context.idToken[namespace + ‘roles’] = role;
context.idToken[namespace + ‘customUserId’] = user.app_metadata.customUserId;

callback(null, user, context);
}

User Json:

{
“phone_number”: “+1508314002”,
“phone_verified”: true,
“name”: “+1508314002”,
“updated_at”: “2018-06-20T12:44:12.524Z”,
“picture”: “https://cdn.auth0.com/avatars/9.png”,
“user_id”: “sms|5b20e76e3020501cdsad4e75e66”,
“nickname”: “+972508314002”,
“identities”: [
{
“user_id”: “5b20e76edssa3020501cd4e75e66”,
“provider”: “sms”,
“connection”: “sms”,
“isSocial”: false
}
],
“created_at”: “2018-06-13T09:45:01.171Z”,
“app_metadata”: {
“role”: [
“admin”
],
“customUserId”: “1234567890”
},
“last_ip”: “109.67.6.143”,
“last_login”: “2018-06-19T09:27:28.141Z”,
“logins_count”: 5,
“blocked_for”: [],
“guardian_authenticators”: []
}