File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2929 escapeHtml ( name ) +
3030 '</span><button type="button" id="coderic-logout-btn" class="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-100 rounded-md hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-orange-500">Cerrar sesión</button>' ;
3131 document . getElementById ( "coderic-logout-btn" ) . addEventListener ( "click" , function ( ) {
32+ window . CodericAccountProfile = null ;
3233 window . CodericAuth0Client . logout ( {
3334 logoutParams : { returnTo : redirectUri } ,
3435 } ) ;
3536 } ) ;
37+ fetchAndSetAccountProfile ( ) ;
38+ }
39+
40+ /** Obtiene /api/account/profile y lo expone en window.CodericAccountProfile para todo el sitio. */
41+ function fetchAndSetAccountProfile ( ) {
42+ if ( ! window . CodericAuth0Client ) return ;
43+ window . CodericAuth0Client . getTokenSilently ( )
44+ . then ( function ( token ) {
45+ return fetch ( "/api/account/profile" , { headers : { Authorization : "Bearer " + token } } ) ;
46+ } )
47+ . then ( function ( r ) { return r . ok ? r . json ( ) : null ; } )
48+ . then ( function ( data ) {
49+ window . CodericAccountProfile = data || null ;
50+ } )
51+ . catch ( function ( ) {
52+ window . CodericAccountProfile = null ;
53+ } ) ;
3654 }
3755
3856 function escapeHtml ( s ) {
You can’t perform that action at this time.
0 commit comments