
How to test GoodBarber Custom Code with a logged-in user
Need your GoodBarber Custom Code to behave differently for a logged-in user — show premium content, greet a member by name, hide a section from anonymous visitors? Whether you wrote that code yourself or generated it with the AI Extension Builder, it asks the App API who's connected through gb.user.getCurrent(). But the back-office preview has no real login, so for Membership apps that call always lands in the error path. This guide explains how the current user behaves in the preview for every app type, and gives you a copy-paste way to test as a logged-in member. A lot of Custom Code needs to know who is using the app right now: showing premium content, greeting members by name, hiding a section from anonymous visitors, adapting a checkout. The GoodBarber App API gives you the current user through gb.user.getCurrent().And Custom Code isn't only something you write by hand anymore. With GoodBarber's AI Extension Builder, you describe the section you want in plain language and the assistant generates the extension for you — code that plugs straight into the same GoodBarber App API. Hand-written or AI-generated, it calls gb.user.getCurrent() the same way, and you test it the same way. So this guide applies whether you typed the code or prompted for it.But here's the catch every developer eventually hits: inside the back-office preview, there is no logged-in user. The preview is just a render of your app — there's no login screen, no session, nothing to authenticate against.For most app types, GoodBarber quietly works around this for you, so testing "as a logged-in user" just works. For the Membership extension, it doesn't — and that's on purpose. This article walks through how the current user behaves in the preview for each app type, and gives you a simple, copy-paste way to test the trickiest case: a logged-in member.
Design





















