Skip to content

Commit 704a4ea

Browse files
committed
Show register form when user receiving a file is not the correctone
1 parent e31625d commit 704a4ea

File tree

2 files changed

+52
-51
lines changed

2 files changed

+52
-51
lines changed

src/UI/UIWindowSignup.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ function UIWindowSignup(options){
4949
// username
5050
h += `<div style="overflow: hidden;">`;
5151
h += `<label for="username-${internal_id}">${i18n('username')}</label>`;
52-
h += `<input id="username-${internal_id}" class="username" type="text" autocomplete="username" spellcheck="false" autocorrect="off" autocapitalize="off" data-gramm_editor="false"/>`;
52+
h += `<input id="username-${internal_id}" value="${html_encode(options.username ?? '')}" class="username" type="text" autocomplete="username" spellcheck="false" autocorrect="off" autocapitalize="off" data-gramm_editor="false"/>`;
5353
h += `</div>`;
5454
// email
5555
h += `<div style="overflow: hidden; margin-top: 20px;">`;
5656
h += `<label for="email-${internal_id}">${i18n('email')}</label>`;
57-
h += `<input id="email-${internal_id}" class="email" type="email" autocomplete="email" spellcheck="false" autocorrect="off" autocapitalize="off" data-gramm_editor="false"/>`;
57+
h += `<input id="email-${internal_id}" value="${html_encode(options.email ?? '')}" class="email" type="email" autocomplete="email" spellcheck="false" autocorrect="off" autocapitalize="off" data-gramm_editor="false"/>`;
5858
h += `</div>`;
5959
// password
6060
h += `<div style="overflow: hidden; margin-top: 20px; margin-bottom: 20px;">`;

src/initgui.js

+50-49
Original file line numberDiff line numberDiff line change
@@ -210,55 +210,6 @@ window.initgui = async function(options){
210210
}
211211
}
212212

213-
//--------------------------------------------------------------------------------------
214-
// `share_token` provided
215-
// i.e. https://puter.com/?share_token=<share_token>
216-
//--------------------------------------------------------------------------------------
217-
if(window.url_query_params.has('share_token')){
218-
let share_token = window.url_query_params.get('share_token');
219-
220-
fetch(`${puter.APIOrigin}/sharelink/check`, {
221-
"headers": {
222-
"Content-Type": "application/json",
223-
"Authorization": `Bearer ${puter.authToken}`,
224-
},
225-
"body": JSON.stringify({
226-
token: share_token,
227-
}),
228-
"method": "POST",
229-
}).then(response => response.json())
230-
.then(async data => {
231-
// Show register screen
232-
if(data.email && data.email !== window.user.email){
233-
await UIWindowSignup({
234-
reload_on_success: true,
235-
send_confirmation_code: false,
236-
window_options:{
237-
has_head: false
238-
}
239-
});
240-
}
241-
// Show email confirmation screen
242-
else if(data.email && data.email === window.user.email && !window.user.email_confirmed){
243-
// todo show email confirmation window
244-
await UIWindowEmailConfirmationRequired({
245-
stay_on_top: true,
246-
has_head: false
247-
});
248-
}
249-
250-
// show shared item
251-
UIWindow({
252-
path: data.path,
253-
title: path.basename(data.path),
254-
icon: await item_icon({is_dir: data.is_dir, path: data.path}),
255-
is_dir: data.is_dir,
256-
app: 'explorer',
257-
});
258-
}).catch(error => {
259-
console.error('Error:', error);
260-
})
261-
}
262213
//--------------------------------------------------------------------------------------
263214
// Determine if an app was launched from URL
264215
// i.e. https://puter.com/app/<app_name>
@@ -818,6 +769,56 @@ window.initgui = async function(options){
818769
window.update_sites_cache();
819770
}
820771
}
772+
//--------------------------------------------------------------------------------------
773+
// `share_token` provided
774+
// i.e. https://puter.com/?share_token=<share_token>
775+
//--------------------------------------------------------------------------------------
776+
if(window.url_query_params.has('share_token')){
777+
let share_token = window.url_query_params.get('share_token');
778+
779+
fetch(`${puter.APIOrigin}/sharelink/check`, {
780+
"headers": {
781+
"Content-Type": "application/json",
782+
"Authorization": `Bearer ${puter.authToken}`,
783+
},
784+
"body": JSON.stringify({
785+
token: share_token,
786+
}),
787+
"method": "POST",
788+
}).then(response => response.json())
789+
.then(async data => {
790+
// Show register screen
791+
if(data.email && data.email !== window.user?.email){
792+
await UIWindowSignup({
793+
reload_on_success: true,
794+
email: data.email,
795+
send_confirmation_code: false,
796+
window_options:{
797+
has_head: false
798+
}
799+
});
800+
}
801+
// Show email confirmation screen
802+
else if(data.email && data.email === window.user.email && !window.user.email_confirmed){
803+
// todo show email confirmation window
804+
await UIWindowEmailConfirmationRequired({
805+
stay_on_top: true,
806+
has_head: false
807+
});
808+
}
809+
810+
// show shared item
811+
UIWindow({
812+
path: data.path,
813+
title: path.basename(data.path),
814+
icon: await item_icon({is_dir: data.is_dir, path: data.path}),
815+
is_dir: data.is_dir,
816+
app: 'explorer',
817+
});
818+
}).catch(error => {
819+
console.error('Error:', error);
820+
})
821+
}
821822
// -------------------------------------------------------------------------------------
822823
// Desktop Background
823824
// If we're in fullpage/emebedded/Auth Popup mode, we don't want to load the custom background

0 commit comments

Comments
 (0)