forked from cory/tildefriends
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:
@ -448,6 +448,7 @@ async function refresh_internal(whoami, selected) {
|
||||
return;
|
||||
}
|
||||
if (whoami !== g_whoami || selected !== g_selected) {
|
||||
await app.localStorageSet('whoami', whoami);
|
||||
g_whoami = whoami;
|
||||
g_selected = selected;
|
||||
} else {
|
||||
@ -475,8 +476,7 @@ async function refresh_internal(whoami, selected) {
|
||||
let hash = selected && selected.length == 1 ? selected[0] : null;
|
||||
if (hash !== g_hash) {
|
||||
g_hash = hash;
|
||||
print(g_hash, '=>', hash);
|
||||
//await tfrpc.rpc.set_hash(hash);
|
||||
await tfrpc.rpc.set_hash(hash);
|
||||
}
|
||||
await Promise.all([
|
||||
tfrpc.rpc.set('whoami', whoami),
|
||||
@ -571,6 +571,10 @@ tfrpc.register(async function refresh(whoami, selected) {
|
||||
return refresh_internal(whoami, selected);
|
||||
});
|
||||
|
||||
tfrpc.register(async function createIdentity() {
|
||||
return ssb.createIdentity();
|
||||
});
|
||||
|
||||
async function addAppSources(message) {
|
||||
if (message.mentions) {
|
||||
for (let mention of message.mentions) {
|
||||
@ -607,13 +611,10 @@ core.register('message', async function(m) {
|
||||
});
|
||||
|
||||
async function main() {
|
||||
if (core.user &&
|
||||
core.user.credentials &&
|
||||
core.user.credentials.permissions &&
|
||||
core.user.credentials.permissions.administration) {
|
||||
if (core.user?.credentials?.permissions?.authenticated) {
|
||||
await app.setDocument(utf8Decode(await getFile("index.html")));
|
||||
} 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>');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,13 +43,19 @@
|
||||
</md-app-toolbar>
|
||||
<md-app class="md-elevation-8">
|
||||
<md-app-toolbar>
|
||||
<div>Welcome, <tf-user :id="whoami"></tf-user>
|
||||
<div>Welcome, <tf-user :id="whoami"></tf-user></div>
|
||||
<div>
|
||||
<md-field>
|
||||
<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-select>
|
||||
</md-field>
|
||||
</div>
|
||||
<div>
|
||||
<md-button @click="create_identity()">
|
||||
Create Identity
|
||||
</md-button>
|
||||
</div>
|
||||
</md-app-toolbar>
|
||||
<md-app-content>
|
||||
<span v-if="load_time">
|
||||
|
@ -327,7 +327,16 @@ window.addEventListener('load', function() {
|
||||
} else {
|
||||
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();
|
||||
|
Reference in New Issue
Block a user