mirror of
https://github.com/hack-chat/main.git
synced 2024-03-22 13:20:33 +08:00
Extended trip length to ten characters
This commit is contained in:
parent
b80b5ca9d1
commit
9982207983
|
@ -15,6 +15,8 @@ const {
|
|||
createHash,
|
||||
} = await import('crypto');
|
||||
|
||||
const TripLength = 10;
|
||||
|
||||
/**
|
||||
* Object defining labels for default permission ranges
|
||||
* @typedef {Object} levels
|
||||
|
@ -150,7 +152,7 @@ export function getUserPerms(pass, salt, config, channel) {
|
|||
|
||||
const sha = createHash('sha256');
|
||||
sha.update(pass + salt);
|
||||
const trip = sha.digest('base64').substr(0, 6);
|
||||
const trip = sha.digest('base64').substr(0, TripLength);
|
||||
|
||||
// check if user is global admin
|
||||
if (trip === config.adminTrip) {
|
||||
|
|
|
@ -18,6 +18,8 @@ const SessionLocation = './session.key';
|
|||
const SaltLocation = './salt.key';
|
||||
const AppConfigLocation = './config.json';
|
||||
|
||||
const TripLength = 10;
|
||||
|
||||
// default configuration options
|
||||
const defaultConfig = {
|
||||
adminTrip: '',
|
||||
|
@ -105,7 +107,7 @@ const checkPermissions = async () => {
|
|||
|
||||
const sha = crypto.createHash('sha256');
|
||||
sha.update(password + salt);
|
||||
config.data.adminTrip = sha.digest('base64').substr(0, 6);
|
||||
config.data.adminTrip = sha.digest('base64').substr(0, TripLength);
|
||||
|
||||
await config.write();
|
||||
} else {
|
||||
|
|
|
@ -42,7 +42,7 @@ describe('Checking UAC module', () => {
|
|||
|
||||
it('should return admin level labels', async () => {
|
||||
const newConfig = Object.assign({}, mocks.core.appConfig.data);
|
||||
newConfig.adminTrip = 'Tt8H7c';
|
||||
newConfig.adminTrip = 'Tt8H7clbL9';
|
||||
const resp = importedModule.getUserPerms('test', 'salt', newConfig, 'cake');
|
||||
expect(resp).to.be.an('object');
|
||||
});
|
||||
|
@ -50,7 +50,7 @@ describe('Checking UAC module', () => {
|
|||
it('should return mod level labels', async () => {
|
||||
const newConfig = Object.assign({}, mocks.core.appConfig.data);
|
||||
newConfig.globalMods = [{
|
||||
trip: 'Tt8H7c',
|
||||
trip: 'Tt8H7clbL9',
|
||||
}];
|
||||
const resp = importedModule.getUserPerms('test', 'salt', newConfig, 'cake');
|
||||
expect(resp).to.be.an('object');
|
||||
|
|
Loading…
Reference in New Issue
Block a user