11<!DOCTYPE html>  
2- < html > 
3- < head > 
4-     < title > Profile Page</ title > 
5- </ head > 
6- < body > 
2+ < html  xmlns:th ="http://www.thymeleaf.org "> 
3+   < head > 
4+     < link 
5+       rel ="stylesheet "
6+       href ="https://unpkg.com/@corbado/web-js@2.8.0/dist/bundle/index.css "
7+       /> 
8+       < script  src ="https://unpkg.com/@corbado/web-js@2.8.0/dist/bundle/index.js " defer > </ script > 
9+     </ head > 
10+     < body > 
11+       
12+      <!-- Define passkey-list div and logout button --> 
13+     < h2 > :/protected</ h2 > 
14+     < p > User ID: [[${USER_ID}]]</ p > 
15+     < p > Name: [[${USER_NAME}]]</ p > 
16+     < p > Email: [[${USER_EMAIL}]]</ p > 
17+     < div  id ="passkey-list "> </ div > 
18+     < button  id ="logoutButton "> Logout</ button > 
719
8- < h2 > :/protected 🔒</ h2 > 
9- < p > User ID: < span  th:text ="${USER_ID} "> </ span > </ p > 
10- < p > Name: < span  th:text ="${USER_NAME} "> </ span > </ p > 
11- < p > Email: < span  th:text ="${USER_EMAIL} "> </ span > </ p > 
12- <!-- Import Corbado SDK --> 
13- < script  th:src ="'https://' + ${PROJECT_ID} + '.frontendapi.corbado.io/auth.js' "> </ script > 
14- < script  th:src ="'https://' + ${PROJECT_ID} + '.frontendapi.corbado.io/utility.js' "> </ script > 
15- <!-- Logout button --> 
16- < button  id ="logoutButton "> Logout</ button > 
1720
18- < script  th:inline ="javascript "> 
19-     /*<![CDATA[*/ 
20-     const  projectID  =  /*[[@{${PROJECT_ID}}]]*/  '' ; 
21-     const  session  =  new  Corbado . Session ( projectID ) ; 
22-     // Get logout button 
23-     const  logoutButton  =  document . getElementById ( 'logoutButton' ) ; 
21+     <!-- Script to load Corbado and mount PasskeyList UI --> 
22+     < script  th:inline ="javascript "> 
23+         document . addEventListener ( 'DOMContentLoaded' ,  async  ( )  =>  { 
24+             await  Corbado . load ( { 
25+                 projectId : /*[[${PROJECT_ID}]]*/ , 
26+                 darkMode : "off" , 
27+                 setShortSessionCookie : "true"  // set short session cookie automatically 
28+             } ) ;  
29+             
30+             // Get and mount PasskeyList UI 
31+             const  passkeyListElement  =  document . getElementById ( "passkey-list" ) ;  // Element where you want to render PasskeyList UI 
32+             Corbado . mountPasskeyListUI ( passkeyListElement ) ; 
2433
25-     // Add event listener to logout button 
26-     logoutButton . addEventListener ( 'click' ,  function ( )  { 
27-         session . logout ( ) 
28-             . then ( ( )  =>  { 
29-                 window . location . replace ( "/" ) ; 
30-             } ) 
31-             . catch ( err  =>  { 
32-                 console . error ( err ) ; 
34+             // Get logout button 
35+             const  logoutButton  =  document . getElementById ( 'logoutButton' ) ; 
36+             // Add event listener to logout button 
37+             logoutButton . addEventListener ( 'click' ,  function ( )  { 
38+               Corbado . logout ( ) 
39+                     . then ( ( )  =>  { 
40+                         window . location . replace ( "/" ) ; 
41+                     } ) 
42+                     . catch ( err  =>  { 
43+                         console . error ( err ) ; 
44+                     } ) ; 
3345            } ) ; 
34-     } ) ; 
35- </ script > 
46+         } ) ( ) ; 
47+     </ script > 
48+     
49+ 
3650</ body > 
37- </ html > 
51+ </ html > 
0 commit comments