
How to test GoodBarber Custom Code with a logged-in user
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




















