Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

syntex-basic

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

syntex-basic - npm Package Compare versions

Comparing version 1.0.0-b1 to 1.0.0-b10

core/connection-manager.js

130

core/user-manager.js

@@ -5,3 +5,3 @@ const md5 = require('md5');

{
constructor(platform)
constructor(platform, options)
{

@@ -12,3 +12,6 @@ this.users = [];

this.FileManager = platform.FileManager;
this.WebServer = platform.WebServer;
this.permissions = options.permissions || {};
this.FileManager.readFile('data/users.json').then((users) => {

@@ -24,6 +27,6 @@

{
this.logger.log('error', 'Anmeldedaten konnten nicht geladen werden ..');
this.logger.log('error', 'Benutzer konnten nicht geladen werden ..');
this.logger.log('error', 'Das Authentifizierungssystem wurde deaktiviert!');
}
})
});

@@ -36,7 +39,7 @@ setInterval(() => {

{
this.logger.log('update', 'Accounts wurden aktualisiert!');
this.logger.log('update', 'Benutzer wurden aktualisiert!');
}
else if(response.changed)
{
this.logger.log('error', 'Accounts konnten nicht aktualisiert werden!');
this.logger.log('error', 'Benutzer konnten nicht aktualisiert werden!');
}

@@ -46,4 +49,114 @@ });

}, 10000);
this.initWebServer();
}
initWebServer()
{
this.WebServer.addPage('/serverside/auth', (request, response, params, content, post) => {
if(post != null && post.username != null && post.password != null)
{
response.end(JSON.stringify(this.checkLogin(post.username, post.password)));
}
else
{
response.end(JSON.stringify({ success : false, permissions : 0 }));
}
});
this.WebServer.addPage('/serverside/admin/accounts', (request, response, params, content, post) => {
var user = this.getUser({ sessionID : request.headers.session });
if(user != null)
{
if(post != null)
{
if(post.accounts != null && (this.permissions['setUsers'] == null || (user != null && user.permissions >= this.permissions['setUsers'])))
{
this.setUsers(post.accounts);
response.end('Success');
}
else if(post.account != null && (this.permissions['setUser'] == null || (user != null && user.permissions >= this.permissions['setUser'])))
{
response.end(this.setUser(post.account) ? 'Success' : 'Error');
}
else
{
response.end('Error');
}
}
else
{
response.end(JSON.stringify(this.getUsers()));
}
}
else
{
response.end('Error');
}
});
this.WebServer.addPage('/serverside/register', (request, response, params, content, post) => {
var user = this.getUser({ sessionID : request.headers.session }), success = false;
if(this.permissions['addUser'] == null || (user != null && user.permissions >= this.permissions['addUser']))
{
if(post != null && post.account != null && post.account.username != null && post.account.password != null && post.account.name != null && post.account.displayname != null && post.account.fullname != null)
{
if(this.createAccount(post.account))
{
this.logger.log('success', '[' + post.account.fullname + '] wurde von [' + (user != null ? user.fullname : 'System') + '] hinzugefügt!');
//this.NotificationManager.sendNotification('admin/accounts', { title : 'Neuer Benutzer', text : post.account.fullname + ' wurde dem System hinzugefügt!', userID : user.username });
success = true;
}
}
}
response.end(success ? 'Success' : 'Error');
});
this.WebServer.addPage('/serverside/account', (request, response, params, content, post) => {
var user = this.getUser({ sessionID : request.headers.session });
if(user != null)
{
if(post != null)
{
if(post.password != null)
{
if(post.account != null)
{
this.setUser(post.account);
}
response.end(JSON.stringify(this.changePassword(request.headers.session, post.password)));
}
else if(post.account != null)
{
response.end(this.setUser({ username : user.username, ...post.account }) ? 'Success' : 'Error');
}
else
{
response.end('Error');
}
}
else
{
response.end(JSON.stringify(user));
}
}
else
{
response.end('Error');
}
});
}
checkLogin(username, password)

@@ -68,10 +181,7 @@ {

{
if(options.sessionID != null && options.sessionID == md5(this.users[i].username + ':' + this.users[i].password))
if(options.sessionID != null && options.sessionID == md5(this.users[i].username + ':' + this.users[i].password)
|| options.userID != null && options.userID == this.users[i].username)
{
return this.users[i];
}
else if(options.userID != null && options.userID == this.users[i].username)
{
return this.users[i];
}
}

@@ -78,0 +188,0 @@

@@ -1,2 +0,2 @@

let UserManager = require('./core/user-manager.js');
let ConnectionManager = require('./core/connection-manager.js'), RequestManager = require('./core/request-manager.js'), StorageManager = require('./core/storage-manager.js'), UserManager = require('./core/user-manager.js');

@@ -9,6 +9,27 @@ const FileManager = require('syntex-filesystem');

{
this.platform = platform;
this.options = options;
this.FileManager = new FileManager({ baseDirectory : options.path, logger : platform.loggerSpecial }, { enableCache : true });
}
this.UserManager = new UserManager({ ...platform, FileManager : this.FileManager });
getConnectionManager()
{
return this.ConnectionManager = new ConnectionManager({ ...this.platform, RequestManager : this.getRequestManager() });
}
getRequestManager()
{
return this.RequestManager = new RequestManager({ ...this.platform });
}
getStorageManager()
{
return this.StorageManager = new StorageManager({ ...this.platform, FileManager : this.FileManager });
}
getUserManager()
{
return this.UserManager = new UserManager({ ...this.platform, FileManager : this.FileManager }, this.options);
}
}

6

package.json
{
"name": "syntex-basic",
"version": "1.0.0-b1",
"version": "1.0.0-b10",
"description": "A basic module for development",

@@ -12,4 +12,4 @@ "main": "main.js",

"md5": "^2.3.0",
"syntex-filesystem": "1.0.3-b1",
"syntex-logger": "1.0.9-b1"
"syntex-filesystem": "1.0.3-b8",
"syntex-logger": "1.0.9-b2"
},

@@ -16,0 +16,0 @@ "homepage": "https://github.com/SynTexDZN/syntex-basic#readme",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc