How to require a login for a BBIS part

Many times while developing custom parts in BBIS the following question comes up: “How do I require a user to be logged in?”

Like a lot of things in BBIS this isn’t so obvious unless you know the API or you know how to do it from the front-end.

Fortunately this is made easy through the API by calling the following:

API.Users.CurrentUser.IsAnonymous

If it’s true then they aren’t logged in and you can bubble up a friendly message to the user.

To do this from the front-end it’s a small bit of configuration on the part itself. You’ll do this by editing your part and going to the “Targeting & security” tab (this tab exists on all parts). Make sure that there isn’t a check in the “View” column for the “Everyone” row. This allows the page to still load but will not show the part if the user is not logged in. If you want the page to not even be displayed or redirect the user then you will want to change the security for that particular page.

Happy coding!
🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s