Quick question: I need to set some metadata when ...
# talk-kratos
c
Quick question: I need to set some metadata when someone logs in using discord. How can I make a mapping like this work:
Copy code
local claims = {
  email_verified: false,
} + std.extVar('claims');

{
  identity: {
    traits: {
      // Allowing unverified email addresses enables account
      // enumeration attacks,  if the value is used for
      // verification or as a password login identifier.
      //
      // Therefore we only return the email if it (a) exists and (b) is marked verified
      // by Discord.
      [if 'email' in claims && claims.email_verified then 'email' else null]: claims.email,
      username: claims.nickname,
    },
    metadata_public: {
        discord: {
            id: claims.sub,
            name: claims.name,
        },
    },
  },
}