JavaScript for AAD B2C custom UI – public preview

A news from the AAD B2C world at last! It’s only a preview but still – a new feature is a new feature.

Technically two features are moving to a public preview phase:

  • Page contracts
  • JavaScript

Page contracts allow to choose a specific data contract version so in case of a change the policy behaviour remains the same. You need to move to a newly published contract explicitly by updating the code of the custom policy. This is production-good – no (or at least less) unexpected changes from the underlying code.
Switching to page contracts (requires updating custom policy code) allows enabling of JavaScript too.

Enabling custom JavaScript in UI templates for custom policies opens a ton of possibilities. Not without restrictions though. I don’t want to retype documentation but can’t resist from giving a small glimpse in what it can  do:

  • call any REST API (unlimited power!)
  • read AAD B2C parameters from the window object properties (useful to check things like locale or current policy)

and what it can’t:

  • bind clicks on <a> elements (yes, application developers still need to handle error after “Forgot your password?”)
  • most JS frameworks are not supported (now this is intriguing, I will investigate which ones fall into the supported minority)
  • change order of HTML elements (pity, some of them could use reordering instead of arguably clean CSS tricks)

Or maybe it can but you just shouldn’t try for your own good? That’s yet to be verified with a help from someone better with JS than me.

Now I’m eager to check if my wild ideas can work despite a list of limitations. Can’t wait to give them a try!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.