Content Hub Tip #4: Restore access when User sign-in script fails

We all have a moment when we don't pay enough attention at the work we as a developer do. Most of the time, we can just go back in the code, solve the issue and try again. Once in a while, things go a bit different. Within the Content Hub, there is a special type of script that runs for every user that signs in. That's an awesome script to use of course, but it comes with a big caveat. Sitecore says the following in their documentation:

Warning when using Sign-in script

When you're reading this and think. OK, I already screwed up, but how can I fix this? Well, Sitecore has an easy solution for this as well.

You can disable a script through the Web SDK as follows. The only thing to remember is ID of the script. Don't have the ID, just go to the next script. We've got you covered.

Disable script

Execute the following script to output all your script IDs and names. This way you can easily spot your script and its ID.

Find your Script ID

When creating a User sign-in script remember the following points:

  • The scripts should always fail gracefully. Use try/catch blocks to ensure that the process fails gracefully, without blocking the sign-in process
  • Use the script only for external providers, if an internal super signs in, step out of the script
  • Write down the ID of the script, so you can disable it if needed
  • Write logging in the script, so you can easily enable it when needed.
  • Create an internal user as a fallback.
Check out the document here.