Track / expose a list of registered users.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3949 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
6628a5c420
commit
353f2ccc13
13
core/auth.js
13
core/auth.js
@ -101,6 +101,19 @@ function handler(request, response) {
|
||||
if (formData.register == "1") {
|
||||
if (!account &&
|
||||
formData.password == formData.confirm) {
|
||||
let users = new Set();
|
||||
let users_original = gDatabase.get('users');
|
||||
try {
|
||||
users = new Set(JSON.parse(users_original));
|
||||
} catch {
|
||||
}
|
||||
if (!users.has(formData.name)) {
|
||||
users.add(formData.name);
|
||||
}
|
||||
users = JSON.stringify([...users].sort());
|
||||
if (users !== users_original) {
|
||||
gDatabase.set('users', users);
|
||||
}
|
||||
writeSession(session, {name: formData.name});
|
||||
account = {password: hashPassword(formData.password)};
|
||||
gDatabase.set("user:" + formData.name, JSON.stringify(account));
|
||||
|
@ -172,6 +172,13 @@ async function getProcessBlob(blobId, key, options) {
|
||||
}
|
||||
},
|
||||
'user': getUser(process, process),
|
||||
'users': function() {
|
||||
try {
|
||||
return JSON.parse(new Database('auth').get('users'));
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
'apps': user => getApps(user, process),
|
||||
'getSockets': getSockets,
|
||||
'permissionTest': function(permission) {
|
||||
|
Loading…
Reference in New Issue
Block a user