Remove the administrator requirement and allow creating new SSB accounts.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3945 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2022-07-31 20:32:48 +00:00
parent 1775fdd6b5
commit fab2c17b43
4 changed files with 26 additions and 10 deletions

View File

@ -1 +1 @@
{"type":"tildefriends-app","files":{"app.js":"&acYxT0G3CMw7yeOLrSZEyUMddadjz3Tj3s922ufQBcQ=.sha256","index.html":"&zWXxIB5f290SW1LGSasi41hNMJUwWzFTnSGeO/lh5zI=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&smJOHGgIsKwQXeEJD3VbHX4A+vhr1Se54WlSHUP/Km8=.sha256","tf-message.js":"&7M+IUC+xHyc306xRrJcx3TnYpONYLlgCsF80m2M2ws4=.sha256","tf.js":"&FD0n9f4JMrvTFTxNOpMKDPv0e2Cex49G+oWdZOUcd/I=.sha256","commonmark.min.js":"&EP0OeR9zyLwZannz+0ga4s9AGES2RLvvIIQYHqqV6+k=.sha256","vue.js":"&g1wvA+yHl1sVC+eufTsg9If7ZeVyMTBU+h0tks7ZNzE=.sha256","vue-material-theme-default-dark.css":"&RP2nr+2CR18BpHHw5ST9a5GJUCOG9n0G2kuGkcQioWE=.sha256","vue-material.min.css":"&kGbUM2QgFSyHZRzqQb0b+0S3EVIlZ0AXpdiAVjIhou8=.sha256","roboto.css":"&jJv43Om673mQO5JK0jj7714s5E+5Yrf82H6LcDx7wUs=.sha256","material-icons.css":"&a28PdcVvgq/DxyIvJAx/e+ZOEtOuHnr3kjLWKyzH11M=.sha256","tf-shared.js":"&MPINm55jkpz2rrNbwsYl09PKGvbgL3nwgBy6CMQkSnw=.sha256","style.css":"&qegBNCrVUihxffRUxGFuG/6u+0Y6d18zHtfNHBZtZ04=.sha256"}} {"type":"tildefriends-app","files":{"app.js":"&WHHdzbI7ug6XNIzyU52SndurkPDXfxkXdTAIglF76QU=.sha256","index.html":"&VkJWaTAZIuKQJQ95D9f52Sp3VH6Y9y58e2db2nSEF+I=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&smJOHGgIsKwQXeEJD3VbHX4A+vhr1Se54WlSHUP/Km8=.sha256","tf-message.js":"&7M+IUC+xHyc306xRrJcx3TnYpONYLlgCsF80m2M2ws4=.sha256","tf.js":"&taJiSGBI+GveYXLKQRggNnmz2VhHsGwx+e4Zp56Glfg=.sha256","commonmark.min.js":"&EP0OeR9zyLwZannz+0ga4s9AGES2RLvvIIQYHqqV6+k=.sha256","vue.js":"&g1wvA+yHl1sVC+eufTsg9If7ZeVyMTBU+h0tks7ZNzE=.sha256","vue-material-theme-default-dark.css":"&RP2nr+2CR18BpHHw5ST9a5GJUCOG9n0G2kuGkcQioWE=.sha256","vue-material.min.css":"&kGbUM2QgFSyHZRzqQb0b+0S3EVIlZ0AXpdiAVjIhou8=.sha256","roboto.css":"&jJv43Om673mQO5JK0jj7714s5E+5Yrf82H6LcDx7wUs=.sha256","material-icons.css":"&a28PdcVvgq/DxyIvJAx/e+ZOEtOuHnr3kjLWKyzH11M=.sha256","tf-shared.js":"&MPINm55jkpz2rrNbwsYl09PKGvbgL3nwgBy6CMQkSnw=.sha256","style.css":"&qegBNCrVUihxffRUxGFuG/6u+0Y6d18zHtfNHBZtZ04=.sha256"}}

View File

@ -448,6 +448,7 @@ async function refresh_internal(whoami, selected) {
return; return;
} }
if (whoami !== g_whoami || selected !== g_selected) { if (whoami !== g_whoami || selected !== g_selected) {
await app.localStorageSet('whoami', whoami);
g_whoami = whoami; g_whoami = whoami;
g_selected = selected; g_selected = selected;
} else { } else {
@ -475,8 +476,7 @@ async function refresh_internal(whoami, selected) {
let hash = selected && selected.length == 1 ? selected[0] : null; let hash = selected && selected.length == 1 ? selected[0] : null;
if (hash !== g_hash) { if (hash !== g_hash) {
g_hash = hash; g_hash = hash;
print(g_hash, '=>', hash); await tfrpc.rpc.set_hash(hash);
//await tfrpc.rpc.set_hash(hash);
} }
await Promise.all([ await Promise.all([
tfrpc.rpc.set('whoami', whoami), tfrpc.rpc.set('whoami', whoami),
@ -571,6 +571,10 @@ tfrpc.register(async function refresh(whoami, selected) {
return refresh_internal(whoami, selected); return refresh_internal(whoami, selected);
}); });
tfrpc.register(async function createIdentity() {
return ssb.createIdentity();
});
async function addAppSources(message) { async function addAppSources(message) {
if (message.mentions) { if (message.mentions) {
for (let mention of message.mentions) { for (let mention of message.mentions) {
@ -607,13 +611,10 @@ core.register('message', async function(m) {
}); });
async function main() { async function main() {
if (core.user && if (core.user?.credentials?.permissions?.authenticated) {
core.user.credentials &&
core.user.credentials.permissions &&
core.user.credentials.permissions.administration) {
await app.setDocument(utf8Decode(await getFile("index.html"))); await app.setDocument(utf8Decode(await getFile("index.html")));
} else { } else {
await app.setDocument('<div style="color: #f00">Only the administrator can use this app at this time. Login at the top right.</div>'); await app.setDocument('<div style="color: #f00">You must be signed in to use this app at this time. Login at the top right.</div>');
} }
} }

View File

@ -43,13 +43,19 @@
</md-app-toolbar> </md-app-toolbar>
<md-app class="md-elevation-8"> <md-app class="md-elevation-8">
<md-app-toolbar> <md-app-toolbar>
<div>Welcome, <tf-user :id="whoami"></tf-user> <div>Welcome, <tf-user :id="whoami"></tf-user></div>
<div>
<md-field> <md-field>
<md-select v-model="whoami" name="whoami" id="whoami" :change="refresh()"> <md-select v-model="whoami" name="whoami" id="whoami" :change="refresh()">
<md-option v-for="identity in identities" v-bind:key="identity" :value="identity">{{identity}}</md-option> <md-option v-for="identity in identities" v-bind:key="identity" :value="identity">{{identity}}</md-option>
</md-select> </md-select>
</md-field> </md-field>
</div> </div>
<div>
<md-button @click="create_identity()">
Create Identity
</md-button>
</div>
</md-app-toolbar> </md-app-toolbar>
<md-app-content> <md-app-content>
<span v-if="load_time"> <span v-if="load_time">

View File

@ -327,7 +327,16 @@ window.addEventListener('load', function() {
} else { } else {
return bytes; return bytes;
} }
},
create_identity() {
if (confirm("Are you sure you would like to create a new identity?")) {
tfrpc.rpc.createIdentity().then(function(id) {
alert(`Identity '${id}' created.`);
}).catch(function(e) {
alert('Error creating a new identity: ' + e);
});
} }
},
} }
}); });
tfrpc.rpc.ready(); tfrpc.rpc.ready();