@@ 448-466 (lines=19) @@ | ||
445 | $aPassword = explode('$', $strPasswordHash); |
|
446 | count($aPassword) == 1 ? $password_hash = $this->getHash($current, 0) : $password_hash = $this->getHash($current, $aPassword[1], $aPassword[2]); |
|
447 | $new = $this->getHash($new1, HASH_VERSION, bin2hex(openssl_random_pseudo_bytes(32))); |
|
448 | if ($this->config['twofactor']['enabled'] && $this->config['twofactor']['options']['changepw']) { |
|
449 | $tValid = $this->token->isTokenValid($userID, $strToken, 6); |
|
450 | if ($tValid) { |
|
451 | if ($this->token->deleteToken($strToken)) { |
|
452 | $this->log->log("info", $this->getUserName($userID)." deleted change password token"); |
|
453 | // token deleted, continue |
|
454 | } else { |
|
455 | $this->log->log("warn", $this->getUserName($userID)." failed to delete the change password token"); |
|
456 | $this->setErrorMessage('Token deletion failed'); |
|
457 | return false; |
|
458 | } |
|
459 | } else { |
|
460 | $this->log->log("error", $this->getUserName($userID)." attempted to use an invalid change password token"); |
|
461 | $this->setErrorMessage('Invalid token'); |
|
462 | return false; |
|
463 | } |
|
464 | } |
|
465 | $stmt = $this->mysqli->prepare("UPDATE $this->table SET pass = ? WHERE ( id = ? AND pass = ? )"); |
|
466 | if ($this->checkStmt($stmt)) { |
|
467 | $stmt->bind_param('sis', $new, $userID, $password_hash); |
|
468 | $stmt->execute(); |
|
469 | if ($stmt->errno == 0 && $stmt->affected_rows === 1) { |
|
@@ 541-558 (lines=18) @@ | ||
538 | $donate = min(100, max(0, floatval($donate))); |
|
539 | ||
540 | // twofactor - consume the token if it is enabled and valid |
|
541 | if ($this->config['twofactor']['enabled'] && $this->config['twofactor']['options']['details']) { |
|
542 | $tValid = $this->token->isTokenValid($userID, $strToken, 5); |
|
543 | if ($tValid) { |
|
544 | if ($this->token->deleteToken($strToken)) { |
|
545 | $this->log->log("info", $this->getUserName($userID)." deleted account update token"); |
|
546 | } else { |
|
547 | $this->setErrorMessage('Token deletion failed'); |
|
548 | $this->log->log("warn", $this->getUserName($userID)." updated their account details but failed to delete token"); |
|
549 | return false; |
|
550 | } |
|
551 | } else { |
|
552 | $this->setErrorMessage('Invalid token'); |
|
553 | $this->log->log("warn", $this->getUserName($userID)." attempted to use an invalid token account update token"); |
|
554 | return false; |
|
555 | } |
|
556 | } |
|
557 | ||
558 | // If we hide our email or it's not set, fetch current one to update |
|
559 | if ($email == 'hidden' || $email == NULL) |
|
560 | $email = $this->getUserEmailById($userID); |
|
561 | // We passed all validation checks so update the account |