fix issue with two session managers on top of each other

This commit is contained in:
Nariman Jelveh 2024-04-12 20:43:15 -07:00
parent 00e9f922c0
commit be55e447bb
2 changed files with 9 additions and 4 deletions

View File

@ -40,7 +40,7 @@ Make sure the development server is running.
```html
<html>
<body>
<script src="http://127.0.0.1:8080/dist/puter.dev.js"></script>
<script src="http://puter.localhost:4100/sdk/puter.dev.js"></script>
<script>
// Loading ...
puter.print(`Loading...`);

View File

@ -62,6 +62,8 @@ window.initgui = async function(){
let url = new URL(window.location);
url = url.href;
let picked_a_user_for_sdk_login = false;
// update SDK if auth_token is different from the one in the SDK
if(window.auth_token && puter.authToken !== window.auth_token)
puter.setAuthToken(window.auth_token);
@ -168,13 +170,16 @@ window.initgui = async function(){
await getUserAppToken(openerOrigin);
}
else if(action === 'sign-in' && is_auth()){
if(await UIWindowSessionList({
picked_a_user_for_sdk_login = await UIWindowSessionList({
reload_on_success: false,
draggable_body: false,
has_head: false,
cover_page: true,
}))
});
if(picked_a_user_for_sdk_login){
await getUserAppToken(openerOrigin);
}
}
}
@ -252,7 +257,7 @@ window.initgui = async function(){
let response = await checkUserSiteRelationship(openerOrigin);
window.userAppToken = response.token;
if(logged_in_users.length > 0 && (!userAppToken || url_query_params.get('request_auth') )){
if(!picked_a_user_for_sdk_login && logged_in_users.length > 0 && (!userAppToken || url_query_params.get('request_auth') )){
await UIWindowSessionList({
reload_on_success: false,
draggable_body: false,