1
0
mirror of https://github.com/delight-im/PHP-Auth.git synced 2025-07-10 11:06:23 +02:00

Determine if configuration had actually been active when disabling 2FA

This commit is contained in:
Marco
2025-05-27 09:59:15 +02:00
parent 2d2ff46121
commit cdcc82040f

View File

@ -2620,8 +2620,10 @@ final class Auth extends UserManager {
*/ */
public function disableTwoFactorViaTotp() { public function disableTwoFactorViaTotp() {
if ($this->isLoggedIn()) { if ($this->isLoggedIn()) {
$disabled = 0;
try { try {
$this->db->exec( $disabled = (int) $this->db->exec(
'DELETE FROM ' . $this->makeTableName('users_2fa') . ' WHERE user_id = ? AND mechanism = ? AND expires_at IS NULL', 'DELETE FROM ' . $this->makeTableName('users_2fa') . ' WHERE user_id = ? AND mechanism = ? AND expires_at IS NULL',
[ $this->getUserId(), self::TWO_FACTOR_MECHANISM_TOTP ] [ $this->getUserId(), self::TWO_FACTOR_MECHANISM_TOTP ]
); );
@ -2644,8 +2646,10 @@ final class Auth extends UserManager {
*/ */
public function disableTwoFactorViaSms() { public function disableTwoFactorViaSms() {
if ($this->isLoggedIn()) { if ($this->isLoggedIn()) {
$disabled = 0;
try { try {
$this->db->exec( $disabled = (int) $this->db->exec(
'DELETE FROM ' . $this->makeTableName('users_2fa') . ' WHERE user_id = ? AND mechanism = ? AND expires_at IS NULL', 'DELETE FROM ' . $this->makeTableName('users_2fa') . ' WHERE user_id = ? AND mechanism = ? AND expires_at IS NULL',
[ $this->getUserId(), self::TWO_FACTOR_MECHANISM_SMS ] [ $this->getUserId(), self::TWO_FACTOR_MECHANISM_SMS ]
); );
@ -2668,8 +2672,10 @@ final class Auth extends UserManager {
*/ */
public function disableTwoFactorViaEmail() { public function disableTwoFactorViaEmail() {
if ($this->isLoggedIn()) { if ($this->isLoggedIn()) {
$disabled = 0;
try { try {
$this->db->exec( $disabled = (int) $this->db->exec(
'DELETE FROM ' . $this->makeTableName('users_2fa') . ' WHERE user_id = ? AND mechanism = ? AND expires_at IS NULL', 'DELETE FROM ' . $this->makeTableName('users_2fa') . ' WHERE user_id = ? AND mechanism = ? AND expires_at IS NULL',
[ $this->getUserId(), self::TWO_FACTOR_MECHANISM_EMAIL ] [ $this->getUserId(), self::TWO_FACTOR_MECHANISM_EMAIL ]
); );
@ -2692,8 +2698,10 @@ final class Auth extends UserManager {
*/ */
public function disableTwoFactor() { public function disableTwoFactor() {
if ($this->isLoggedIn()) { if ($this->isLoggedIn()) {
$disabled = 0;
try { try {
$this->db->exec( $disabled = (int) $this->db->exec(
'DELETE FROM ' . $this->makeTableName('users_2fa') . ' WHERE user_id = ? AND expires_at IS NULL', 'DELETE FROM ' . $this->makeTableName('users_2fa') . ' WHERE user_id = ? AND expires_at IS NULL',
[ $this->getUserId() ] [ $this->getUserId() ]
); );