parent
954794870e
commit
0140cf1a57
|
@ -15,21 +15,7 @@
|
||||||
|
|
||||||
while($rowAuth = $statementAuth->fetch())
|
while($rowAuth = $statementAuth->fetch())
|
||||||
{
|
{
|
||||||
$passwordCorrect = false;
|
return md5(md5($_POST['password']).":".$rowAuth['passwordSalt']) == $rowAuth['passwordHash'];
|
||||||
if(strlen($rowAuth['passwordHash']) == 32) {
|
|
||||||
if(md5(md5($password).":".$rowAuth['passwordSalt']) == $rowAuth['passwordHash']) {
|
|
||||||
$passwordCorrect = true;
|
|
||||||
|
|
||||||
$newHash = password_hash($password, PASSWORD_ARGON2ID);
|
|
||||||
$updateHash = $RUNTIME['PDO']->prepare("UPDATE auth SET passwordHash = ?, passwordSalt = ? WHERE UUID = ?");
|
|
||||||
$updateHash->execute(array($newHash, '', $rowUser['PrincipalID']));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$passwordCorrect = password_verify($password, $rowAuth['passwordHash']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $passwordCorrect;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,21 +29,7 @@
|
||||||
|
|
||||||
while($rowAuth = $statementAuth->fetch())
|
while($rowAuth = $statementAuth->fetch())
|
||||||
{
|
{
|
||||||
$passwordCorrect = false;
|
if(md5(md5($_POST['password']).":".$rowAuth['passwordSalt']) == $rowAuth['passwordHash'])
|
||||||
if(strlen($rowAuth['passwordHash']) == 32) {
|
|
||||||
if(md5(md5($_POST['password']).":".$rowAuth['passwordSalt']) == $rowAuth['passwordHash']) {
|
|
||||||
$passwordCorrect = true;
|
|
||||||
|
|
||||||
$newHash = password_hash($_POST['password'], PASSWORD_ARGON2ID);
|
|
||||||
$updateHash = $RUNTIME['PDO']->prepare("UPDATE auth SET passwordHash = ?, passwordSalt = ? WHERE UUID = ?");
|
|
||||||
$updateHash->execute(array($newHash, '', $rowUser['PrincipalID']));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$passwordCorrect = password_verify($_POST['password'], $rowAuth['passwordHash']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($passwordCorrect)
|
|
||||||
{
|
{
|
||||||
session_unset(); // Unset pre-session variables, next request will generate a new CSRF token
|
session_unset(); // Unset pre-session variables, next request will generate a new CSRF token
|
||||||
$_SESSION['USERNAME'] = trim($_POST['username']);
|
$_SESSION['USERNAME'] = trim($_POST['username']);
|
||||||
|
|
|
@ -132,11 +132,13 @@
|
||||||
if($validator->isValid($_POST)) {
|
if($validator->isValid($_POST)) {
|
||||||
if($_POST['newPasswordRepeat'] == $_POST['newPassword']) {
|
if($_POST['newPasswordRepeat'] == $_POST['newPassword']) {
|
||||||
if(strlen(trim($_POST['newPassword'])) >= $RUNTIME['PASSWORD_MIN_LENGTH']) {
|
if(strlen(trim($_POST['newPassword'])) >= $RUNTIME['PASSWORD_MIN_LENGTH']) {
|
||||||
if(password_verify($_POST['oldPassword'], $_SESSION['PASSWORD'])) {
|
if(md5(md5($_POST['oldPassword']).':'.$_SESSION['SALT']) == $_SESSION['PASSWORD']) {
|
||||||
$hash = password_hash($_POST['newPassword'], PASSWORD_ARGON2ID);
|
$salt = bin2hex(random_bytes(16));
|
||||||
$statement = $RUNTIME['PDO']->prepare('UPDATE auth SET passwordHash = :PasswordHash WHERE UUID = :PrincipalID');
|
$hash = md5(md5(trim($_POST['newPassword'])).':'.$salt);
|
||||||
$statement->execute(['PasswordHash' => $hash, 'PrincipalID' => $_SESSION['UUID']]);
|
$statement = $RUNTIME['PDO']->prepare('UPDATE auth SET passwordHash = :PasswordHash, passwordSalt = :PasswordSalt WHERE UUID = :PrincipalID');
|
||||||
|
$statement->execute(['PasswordHash' => $hash, 'PasswordSalt' => $salt, 'PrincipalID' => $_SESSION['UUID']]);
|
||||||
$_SESSION['PASSWORD'] = $hash;
|
$_SESSION['PASSWORD'] = $hash;
|
||||||
|
$_SESSION['SALT'] = $salt;
|
||||||
$_SESSION['profile_info'] = 'Neues Passwort gespeichert.';
|
$_SESSION['profile_info'] = 'Neues Passwort gespeichert.';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -89,9 +89,10 @@
|
||||||
$opensim = new OpenSim();
|
$opensim = new OpenSim();
|
||||||
|
|
||||||
$avatarUUID = $opensim->gen_uuid();
|
$avatarUUID = $opensim->gen_uuid();
|
||||||
$passwordHash = password_hash($pass, PASSWORD_ARGON2ID);
|
$salt = bin2hex(random_bytes(16));
|
||||||
$statementAuth = $RUNTIME['PDO']->prepare('INSERT INTO `auth` (`UUID`, `passwordHash`, `webLoginKey`, `accountType`) VALUES (:UUID, :HASHVALUE, :WEBKEY, :ACCTYPE)');
|
$passwordHash = md5(md5($pass).':'.$salt);
|
||||||
$statementAuth->execute(['UUID' => $avatarUUID, 'HASHVALUE' => $passwordHash, 'WEBKEY' => "00000000-0000-0000-0000-000000000000", 'ACCTYPE' => "UserAccount"]);
|
$statementAuth = $RUNTIME['PDO']->prepare('INSERT INTO `auth` (`UUID`, `passwordHash`, `passwordSalt`, `webLoginKey`, `accountType`) VALUES (:UUID, :HASHVALUE, :SALT, :WEBKEY, :ACCTYPE)');
|
||||||
|
$statementAuth->execute(['UUID' => $avatarUUID, 'HASHVALUE' => $passwordHash, 'SALT' => $salt, 'WEBKEY' => "00000000-0000-0000-0000-000000000000", 'ACCTYPE' => "UserAccount"]);
|
||||||
$statementAccounts = $RUNTIME['PDO']->prepare('INSERT INTO `UserAccounts` (`PrincipalID`, `ScopeID`, `FirstName`, `LastName`, `Email`, `ServiceURLs`, `Created`, `UserLevel`, `UserFlags`, `UserTitle`, `active`) VALUES (:PrincipalID, :ScopeID, :FirstName, :LastName, :Email, :ServiceURLs, :Created, :UserLevel, :UserFlags, :UserTitle, :active )');
|
$statementAccounts = $RUNTIME['PDO']->prepare('INSERT INTO `UserAccounts` (`PrincipalID`, `ScopeID`, `FirstName`, `LastName`, `Email`, `ServiceURLs`, `Created`, `UserLevel`, `UserFlags`, `UserTitle`, `active`) VALUES (:PrincipalID, :ScopeID, :FirstName, :LastName, :Email, :ServiceURLs, :Created, :UserLevel, :UserFlags, :UserTitle, :active )');
|
||||||
$statementAccounts->execute(['PrincipalID' => $avatarUUID, 'ScopeID' => "00000000-0000-0000-0000-000000000000", 'FirstName' => $nameParts[0], 'LastName' => $nameParts[1], 'Email' => $email, 'ServiceURLs' => "HomeURI= GatekeeperURI= InventoryServerURI= AssetServerURI= ", 'Created' => time(), 'UserLevel' => 0, 'UserFlags' => 0, 'UserTitle' => "", 'active' => 1]);
|
$statementAccounts->execute(['PrincipalID' => $avatarUUID, 'ScopeID' => "00000000-0000-0000-0000-000000000000", 'FirstName' => $nameParts[0], 'LastName' => $nameParts[1], 'Email' => $email, 'ServiceURLs' => "HomeURI= GatekeeperURI= InventoryServerURI= AssetServerURI= ", 'Created' => time(), 'UserLevel' => 0, 'UserFlags' => 0, 'UserTitle' => "", 'active' => 1]);
|
||||||
$statementProfile = $RUNTIME['PDO']->prepare('INSERT INTO `userprofile` (`useruuid`, `profilePartner`, `profileImage`, `profileFirstImage`) VALUES (:useruuid, :profilePartner, :profileImage, :profileFirstImage)');
|
$statementProfile = $RUNTIME['PDO']->prepare('INSERT INTO `userprofile` (`useruuid`, `profilePartner`, `profileImage`, `profileFirstImage`) VALUES (:useruuid, :profilePartner, :profileImage, :profileFirstImage)');
|
||||||
|
@ -119,6 +120,7 @@
|
||||||
$_SESSION['LASTNAME'] = trim($nameParts[1]);
|
$_SESSION['LASTNAME'] = trim($nameParts[1]);
|
||||||
$_SESSION['EMAIL'] = $email;
|
$_SESSION['EMAIL'] = $email;
|
||||||
$_SESSION['PASSWORD'] = $passwordHash;
|
$_SESSION['PASSWORD'] = $passwordHash;
|
||||||
|
$_SESSION['SALT'] = $salt;
|
||||||
$_SESSION['UUID'] = $avatarUUID;
|
$_SESSION['UUID'] = $avatarUUID;
|
||||||
$_SESSION['LEVEL'] = 0;
|
$_SESSION['LEVEL'] = 0;
|
||||||
$_SESSION['DISPLAYNAME'] = strtoupper($name);
|
$_SESSION['DISPLAYNAME'] = strtoupper($name);
|
||||||
|
|
|
@ -23,9 +23,11 @@
|
||||||
|
|
||||||
if($validator->isValid($_POST)) {
|
if($validator->isValid($_POST)) {
|
||||||
$NEWPW = substr(str_shuffle(str_repeat($x='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil(10/strlen($x)) )),1,10); // Generate random password (10 characters)
|
$NEWPW = substr(str_shuffle(str_repeat($x='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil(10/strlen($x)) )),1,10); // Generate random password (10 characters)
|
||||||
|
$salt = bin2hex(random_bytes(16));
|
||||||
|
$hash = md5(md5($NEWPW).':'.$salt);
|
||||||
|
|
||||||
$statement = $RUNTIME['PDO']->prepare('UPDATE auth SET passwordHash = :PasswordHash WHERE UUID = :PrincipalID');
|
$statement = $RUNTIME['PDO']->prepare('UPDATE auth SET passwordHash = :PasswordHash, passwordSalt = :PasswordSalt WHERE UUID = :PrincipalID');
|
||||||
$statement->execute(['PasswordHash' => password_hash($NEWPW, PASSWORD_ARGON2ID), 'PrincipalID' => $_REQUEST['userid']]);
|
$statement->execute(['PasswordHash' => $hash, 'PasswordSalt' => $salt, 'PrincipalID' => $_REQUEST['userid']]);
|
||||||
|
|
||||||
$HTML->ReplaceSeitenInhalt("%%MESSAGE%%", '<div class="alert alert-danger" role="alert">Das Passwort für '.htmlspecialchars($opensim->getUserName($_REQUEST['userid'])).' wurde geändert. Das neue Passwort ist <b>'.htmlspecialchars($NEWPW).'</b></div>');
|
$HTML->ReplaceSeitenInhalt("%%MESSAGE%%", '<div class="alert alert-danger" role="alert">Das Passwort für '.htmlspecialchars($opensim->getUserName($_REQUEST['userid'])).' wurde geändert. Das neue Passwort ist <b>'.htmlspecialchars($NEWPW).'</b></div>');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue