add support to loginparams for handling a prehashed password

This commit is contained in:
Wolfgang von Caron
2021-12-09 18:57:38 +00:00
committed by Casper Warden
parent 618cfe716f
commit 971e57a097
2 changed files with 14 additions and 2 deletions

View File

@@ -1,6 +1,5 @@
import validator from 'validator';
import * as xmlrpc from 'xmlrpc';
import * as crypto from 'crypto';
import * as fs from 'fs';
import * as path from 'path';
import { LoginError } from './classes/LoginError';
@@ -87,7 +86,7 @@ export class LoginHandler
{
'first': params.firstName,
'last': params.lastName,
'passwd': '$1$' + crypto.createHash('md5').update(params.password.substr(0, 16)).digest('hex'),
'passwd': params.getHashedPassword(),
'start': params.start,
'major': '0',
'minor': '0',

View File

@@ -1,3 +1,5 @@
import * as crypto from 'crypto';
export class LoginParameters
{
firstName: string;
@@ -9,4 +11,15 @@ export class LoginParameters
mfa_hash?: string;
agreeToTOS?: true;
readCritical?: true;
passwordPrehashed = false;
getHashedPassword(): string
{
if (this.passwordPrehashed)
{
return this.password;
}
return '$1$' + crypto.createHash('md5').update(this.password.substr(0, 16)).digest('hex');
}
}