File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed
static/examples/cstg-prebid-example Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change 1515 SUBSCRIPTION_ID : '4WvryDGbR5' ,
1616 } ;
1717
18- let attemptedTokenGeneration = false ;
19-
2018 function updateGuiElements ( ) {
2119 console . log ( 'Updating displayed values.' ) ;
2220 const uid2 = pbjs . getUserIds ( ) . uid2 ;
21+
22+ // Check localStorage for opt-out status
23+ const storedToken = localStorage . getItem ( '__uid2_advertising_token' ) ;
24+ let isOptedOut = false ;
25+ if ( storedToken ) {
26+ try {
27+ const tokenData = JSON . parse ( storedToken ) ;
28+ isOptedOut = tokenData . latestToken === 'optout' ;
29+ } catch ( e ) {
30+ console . log ( 'Could not parse stored token' ) ;
31+ }
32+ }
33+
2334 $ ( '#targeted_advertising_ready' ) . text ( uid2 ? 'yes' : 'no' ) ;
2435
25- // If token generation was attempted and uid2 is null, it means opt-out
26- if ( attemptedTokenGeneration && ! uid2 ) {
36+ // Handle opt-out case
37+ if ( isOptedOut ) {
2738 $ ( '#advertising_token' ) . text ( 'This email has opted out.' ) ;
2839 $ ( '#login_form' ) . hide ( ) ;
2940 $ ( '#clear_storage_form' ) . show ( ) ;
3748 $ ( '#clear_storage_form' ) . show ( ) ;
3849 }
3950 }
40-
41- attemptedTokenGeneration = false ;
4251 }
4352
4453 async function handleLogin ( ) {
4554 const email = $ ( '#email' ) . val ( ) ;
46- attemptedTokenGeneration = true ;
4755 setUid2Config ( email ) ;
4856 await pbjs . refreshUserIds ( ) ;
4957 updateGuiElements ( ) ;
You can’t perform that action at this time.
0 commit comments