change bcrypt dep, fix buildHome
This commit is contained in:
157
ssr/buildHome.ts
157
ssr/buildHome.ts
@@ -36,46 +36,129 @@ export default async (userId: string, userName: string) => {
|
||||
|
||||
return `<div>
|
||||
<script>
|
||||
const actionMethod = new Map([['rename','PUT'],['move','PUT'],['undelete','PUT'],['delete','DELETE'],['perm-delete','DELETE']]);
|
||||
function doAction(action,planId){
|
||||
let newName='';
|
||||
if(action==='rename'||action==='move'){newName=prompt(\`Please provide a new \${action==='rename'?'plan':'folder'} name:\`);if(!newName){return;}}
|
||||
let userName=localStorage.getItem('name');
|
||||
if(!userName){userName=prompt('Please enter your username:');if(!userName){return;}}
|
||||
const userPIN=prompt('Please enter your PIN:');
|
||||
fetch(\`/api/\${action}/\${planId}\`,{method:actionMethod.get(action),body:JSON.stringify({name:userName,pin:userPIN,folder:newName,planName:newName})})
|
||||
.catch((e)=>{e.text().then((text)=>{alert(text);});})
|
||||
.then((r) => {
|
||||
if(r.status===200){localStorage.setItem('name',userName);r.text().then((text)=>{alert(text);window.location.reload();});}
|
||||
else{r.text().then((text)=>{alert(text);});}
|
||||
});
|
||||
const actionMethod = new Map([
|
||||
['rename', 'PUT'],
|
||||
['move', 'PUT'],
|
||||
['undelete', 'PUT'],
|
||||
['delete', 'DELETE'],
|
||||
['perm-delete', 'DELETE'],
|
||||
]);
|
||||
function doAction(action, planId) {
|
||||
let newName = '';
|
||||
if (action === 'rename' || action === 'move') {
|
||||
newName = prompt(\`Please provide a new \${action==='rename'?'plan':'folder'} name:\`);
|
||||
if (!newName) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
let userName = localStorage.getItem('name');
|
||||
if (!userName) {
|
||||
userName = prompt('Please enter your username:');
|
||||
if (!userName) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
const userPIN = prompt('Please enter your PIN:');
|
||||
fetch(\`/api/\${action}/\${planId}\`, {
|
||||
method: actionMethod.get(action),
|
||||
body: JSON.stringify({ name: userName, pin: userPIN, folder: newName, planName: newName }),
|
||||
})
|
||||
.catch((e) => {
|
||||
e.text().then((text) => {
|
||||
alert(text);
|
||||
});
|
||||
})
|
||||
.then((r) => {
|
||||
if (r.status === 200) {
|
||||
localStorage.setItem('name', userName);
|
||||
r.text().then((text) => {
|
||||
alert(text);
|
||||
window.location.reload();
|
||||
});
|
||||
} else {
|
||||
r.text().then((text) => {
|
||||
alert(text);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
function exportPlans(){
|
||||
fetch('/api/export/${userId}')
|
||||
.catch((e)=>{e.text().then((text)=>{alert(text);});})
|
||||
.then((r)=>{r.text().then((text)=>{alert(text);});});
|
||||
function exportPlans() {
|
||||
fetch('/api/export/${userId}')
|
||||
.catch((e) => {
|
||||
e.text().then((text) => {
|
||||
alert(text);
|
||||
});
|
||||
})
|
||||
.then((r) => {
|
||||
r.text().then((text) => {
|
||||
alert(text);
|
||||
});
|
||||
});
|
||||
}
|
||||
function openPlan(planId){window.open(\`${config.api.publicDomain}share#\${planId}\`);}
|
||||
async function sharePlan(planId){
|
||||
const link=\`${config.api.publicDomain}share#\${planId}\`;
|
||||
try{await navigator.clipboard.writeText(link);alert('Link copied to clipboard');}
|
||||
catch (error){prompt('Failed to copy to clipboard, please select and copy the link below:',link);}
|
||||
function openPlan(planId) {
|
||||
window.open(\`${config.api.publicDomain}share#\${planId}\`);
|
||||
}
|
||||
function deleteAccount(){
|
||||
const userName=prompt('Please enter your username:')
|
||||
if(!userName.trim()){return;}
|
||||
const userPin=prompt('Please enter your PIN:');
|
||||
if(!userPin.trim()){return;}
|
||||
if(!confirm('Are you sure you want to delete your account? This is permanent and irreversible, and will delete all plans saved to your account as well.')){return;}
|
||||
fetch('/api/auth',{method:'POST',body:JSON.stringify({name:userName.trim(),pin:userPin.trim()})})
|
||||
.catch((e)=>{e.text().then((text)=>{alert(text);});})
|
||||
.then((r) => {if(r.status===200){r.json().then((j)=>{
|
||||
let deleteCode='';if(j.hasEmail&&j.deleteCodeSet)deleteCode=prompt('Please enter the Delete Code emailed to you (if you don\'t see it, please check your spam folder):');
|
||||
if(j.hasEmail&&j.deleteCodeSet&&!deleteCode){alert('Delete code required.');return;}
|
||||
fetch('/api/unenroll',{method:'DELETE',body:JSON.stringify({name:userName.trim(),pin:userPin.trim(),deleteCode:deleteCode.trim()})})
|
||||
.catch((e)=>{e.text().then((text)=>{alert(text);});})
|
||||
.then((r) => {if(r.status===200){alert('Account and plans deleted.');window.location.reload();}else{r.text().then((text)=>{alert(text);});}});
|
||||
});}else{r.text().then((text)=>{alert(text);});}});
|
||||
async function sharePlan(planId) {
|
||||
const link = \`${config.api.publicDomain}share#\${planId}\`;
|
||||
try {
|
||||
await navigator.clipboard.writeText(link);
|
||||
alert('Link copied to clipboard');
|
||||
} catch (error) {
|
||||
prompt('Failed to copy to clipboard, please select and copy the link below:', link);
|
||||
}
|
||||
}
|
||||
function deleteAccount() {
|
||||
const userName = prompt('Please enter your username:');
|
||||
if (!userName.trim()) {
|
||||
return;
|
||||
}
|
||||
const userPin = prompt('Please enter your PIN:');
|
||||
if (!userPin.trim()) {
|
||||
return;
|
||||
}
|
||||
if (!confirm('Are you sure you want to delete your account? This is permanent and irreversible, and will delete all plans saved to your account as well.')) {
|
||||
return;
|
||||
}
|
||||
fetch('/api/auth', { method: 'POST', body: JSON.stringify({ name: userName.trim(), pin: userPin.trim() }) })
|
||||
.catch((e) => {
|
||||
e.text().then((text) => {
|
||||
alert(text);
|
||||
});
|
||||
})
|
||||
.then((r) => {
|
||||
if (r.status === 200) {
|
||||
r.json().then((j) => {
|
||||
let deleteCode = '';
|
||||
if (j.hasEmail && j.deleteCodeSet) {
|
||||
deleteCode = prompt("Please enter the Delete Code emailed to you (if you don't see it, please check your spam folder):");
|
||||
}
|
||||
if (j.hasEmail && j.deleteCodeSet && !deleteCode) {
|
||||
alert('Delete code required.');
|
||||
return;
|
||||
}
|
||||
fetch('/api/unenroll', { method: 'DELETE', body: JSON.stringify({ name: userName.trim(), pin: userPin.trim(), deleteCode: deleteCode.trim() }) })
|
||||
.catch((e) => {
|
||||
e.text().then((text) => {
|
||||
alert(text);
|
||||
});
|
||||
})
|
||||
.then((r) => {
|
||||
if (r.status === 200) {
|
||||
alert('Account and plans deleted.');
|
||||
window.location.reload();
|
||||
} else {
|
||||
r.text().then((text) => {
|
||||
alert(text);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
r.text().then((text) => {
|
||||
alert(text);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<p>This is a very basic management page. Please excuse the number of alert/prompts that will come up when you click on things as it was the quickest way to build it out.</p>
|
||||
|
||||
Reference in New Issue
Block a user