Our creatives units enables an authenticate-for-reward pattern, using the login optin feature: we'll invite the user to subscribe to a newsletter before they can see the results.
While this works well for most publishers, some might want to leverage the units for their own login system. For that purpose, we provide an API.
Tell the SDK about the user login status
We provide a
__logUser function, in which you can pass the user login status:
true: the user is logged in
false: the user isn't logged
Provide a way to trigger the auth flow
In the case the user is not yet logged in, the unit will call your auth flow so that you can show the auth modal or redirect.
If the login happens directly on the page (or that you auth popup can communicate using the
postMessage API), you can return a promise that resolves with
true if the login is successful, or
false if not.
If your auth requires a redirect, simply change the page location, and make the flow go back to the initial page, the widget will then reload at the correct step and show the results.
Requiring login on creative units
In order to enable the login flow, go to the creative you want it enabled on, simply click on Require user login and pick Optional or Required.
If we sum all this up, your login setup should look like this: