forked from cory/tildefriends
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 (formData.register == "1") {
|
||||||
if (!account &&
|
if (!account &&
|
||||||
formData.password == formData.confirm) {
|
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});
|
writeSession(session, {name: formData.name});
|
||||||
account = {password: hashPassword(formData.password)};
|
account = {password: hashPassword(formData.password)};
|
||||||
gDatabase.set("user:" + formData.name, JSON.stringify(account));
|
gDatabase.set("user:" + formData.name, JSON.stringify(account));
|
||||||
|
@ -172,6 +172,13 @@ async function getProcessBlob(blobId, key, options) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
'user': getUser(process, process),
|
'user': getUser(process, process),
|
||||||
|
'users': function() {
|
||||||
|
try {
|
||||||
|
return JSON.parse(new Database('auth').get('users'));
|
||||||
|
} catch {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
},
|
||||||
'apps': user => getApps(user, process),
|
'apps': user => getApps(user, process),
|
||||||
'getSockets': getSockets,
|
'getSockets': getSockets,
|
||||||
'permissionTest': function(permission) {
|
'permissionTest': function(permission) {
|
||||||
|
Loading…
Reference in New Issue
Block a user