Skip to content

Commit 26e9d9e

Browse files
committed
Add the attempt_temp_user_creation option to puter.auth.signIn()
1 parent d7b731a commit 26e9d9e

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/gui/src/initgui.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,14 @@ window.initgui = async function(options){
225225
// Launch services before any UI is rendered
226226
await launch_services(options);
227227

228+
//--------------------------------------------------------------------------------------
229+
// Is attempt_temp_user_creation?
230+
// i.e. https://puter.com/?attempt_temp_user_creation=true
231+
//--------------------------------------------------------------------------------------
232+
if(window.url_query_params.has('attempt_temp_user_creation') && (window.url_query_params.get('attempt_temp_user_creation') === 'true' || window.url_query_params.get('attempt_temp_user_creation') === '1')){
233+
window.attempt_temp_user_creation = true;
234+
}
235+
228236
//--------------------------------------------------------------------------------------
229237
// Is GUI embedded in a popup?
230238
// i.e. https://puter.com/?embedded_in_popup=true
@@ -248,7 +256,7 @@ window.initgui = async function(options){
248256
// this is the referrer in terms of user acquisition
249257
window.referrerStr = window.openerOrigin;
250258

251-
if(action === 'sign-in' && !window.is_auth()){
259+
if(action === 'sign-in' && !window.is_auth() && !(window.attempt_temp_user_creation && window.first_visit_ever)){
252260
// show signup window
253261
if(await UIWindowSignup({
254262
reload_on_success: false,
@@ -261,7 +269,7 @@ window.initgui = async function(options){
261269
}))
262270
await window.getUserAppToken(window.openerOrigin);
263271
}
264-
else if(action === 'sign-in' && window.is_auth()){
272+
else if(action === 'sign-in' && window.is_auth() && !(window.attempt_temp_user_creation && window.first_visit_ever)){
265273
picked_a_user_for_sdk_login = await UIWindowSessionList({
266274
reload_on_success: false,
267275
draggable_body: false,

src/puter-js/src/modules/Auth.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ class Auth{
4242
this.APIOrigin = APIOrigin;
4343
}
4444

45-
signIn = () =>{
45+
signIn = (options) =>{
46+
options = options || {};
47+
4648
return new Promise((resolve, reject) => {
4749
let msg_id = this.#messageID++;
4850
let w = 600;
@@ -52,7 +54,7 @@ class Auth{
5254
var top = (screen.height/2)-(h/2);
5355

5456
// Store reference to the popup window
55-
const popup = window.open(puter.defaultGUIOrigin + '/action/sign-in?embedded_in_popup=true&msg_id=' + msg_id + (window.crossOriginIsolated ? '&cross_origin_isolated=true' : ''),
57+
const popup = window.open(puter.defaultGUIOrigin + '/action/sign-in?embedded_in_popup=true&msg_id=' + msg_id + (window.crossOriginIsolated ? '&cross_origin_isolated=true' : '') +(options.attempt_temp_user_creation ? '&attempt_temp_user_creation=true' : ''),
5658
title,
5759
'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
5860

0 commit comments

Comments
 (0)