Allow disabling 2fa based on pgp
This commit is contained in:
2 files changed
+11
-4
No files matched your search
@@ -684,7 +684,6 @@ function send_edit_admin(): void
|
|||||||
<p><?php echo htmlspecialchars(_('Add this secret to your authenticator app, then enter the generated code to enable TOTP.')); ?></p>
|
<p><?php echo htmlspecialchars(_('Add this secret to your authenticator app, then enter the generated code to enable TOTP.')); ?></p>
|
||||||
<p><img src="<?php echo htmlspecialchars( $totp_qr ); ?>" alt="<?php echo htmlspecialchars(_('TOTP setup QR code')); ?>" width="220" height="220"></p>
|
<p><img src="<?php echo htmlspecialchars( $totp_qr ); ?>" alt="<?php echo htmlspecialchars(_('TOTP setup QR code')); ?>" width="220" height="220"></p>
|
||||||
<p><strong><?php echo htmlspecialchars($_SESSION[ 'admin_totp_setup' ]); ?></strong></p>
|
<p><strong><?php echo htmlspecialchars($_SESSION[ 'admin_totp_setup' ]); ?></strong></p>
|
||||||
<p><a href="<?php echo htmlspecialchars( $totp_uri ); ?>"><?php echo htmlspecialchars(_('Open authenticator setup link')); ?></a></p>
|
|
||||||
<form class="form_limit" action="admin.php" method="post">
|
<form class="form_limit" action="admin.php" method="post">
|
||||||
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION[ 'csrf_token' ]; ?>">
|
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION[ 'csrf_token' ]; ?>">
|
||||||
<input type="hidden" name="action" value="enable_admin_totp">
|
<input type="hidden" name="action" value="enable_admin_totp">
|
||||||
|
|||||||
+11
-3
@@ -196,6 +196,10 @@ if ( $_SERVER[ 'REQUEST_METHOD' ] === 'POST' ) {
|
|||||||
$stmt->execute( [ $_SESSION[ 'email_user' ] ] );
|
$stmt->execute( [ $_SESSION[ 'email_user' ] ] );
|
||||||
$msg .= '<p class="green">'.htmlspecialchars(_('Successfully enabled 2FA')).'</p>';
|
$msg .= '<p class="green">'.htmlspecialchars(_('Successfully enabled 2FA')).'</p>';
|
||||||
}
|
}
|
||||||
|
} elseif ( $_POST[ 'action' ] === 'disable_pgp_2fa' && ! empty( $_SESSION[ 'email_user' ] ) ) {
|
||||||
|
$stmt = $db->prepare( 'UPDATE mailbox SET tfa = 0 WHERE username = ? AND active = 1;' );
|
||||||
|
$stmt->execute( [ $_SESSION[ 'email_user' ] ] );
|
||||||
|
$msg .= '<p class="green">'.htmlspecialchars(_('Successfully disabled two-factor authentication')).'</p>';
|
||||||
} elseif ( $_POST[ 'action' ] === 'start_totp_setup' && ! empty( $_SESSION[ 'email_user' ] ) ) {
|
} elseif ( $_POST[ 'action' ] === 'start_totp_setup' && ! empty( $_SESSION[ 'email_user' ] ) ) {
|
||||||
$_SESSION[ 'user_totp_setup' ] = generate_totp_secret();
|
$_SESSION[ 'user_totp_setup' ] = generate_totp_secret();
|
||||||
} elseif ( $_POST[ 'action' ] === 'enable_totp' && ! empty( $_SESSION[ 'email_user' ] ) && ! empty( $_SESSION[ 'user_totp_setup' ] ) ) {
|
} elseif ( $_POST[ 'action' ] === 'enable_totp' && ! empty( $_SESSION[ 'email_user' ] ) && ! empty( $_SESSION[ 'user_totp_setup' ] ) ) {
|
||||||
@@ -423,7 +427,6 @@ if ( empty( $_SESSION[ 'email_user' ] ) ) { ?>
|
|||||||
<p><?php echo htmlspecialchars(_('Add this secret to your authenticator app, then enter the generated code to enable TOTP.')); ?></p>
|
<p><?php echo htmlspecialchars(_('Add this secret to your authenticator app, then enter the generated code to enable TOTP.')); ?></p>
|
||||||
<p><img src="<?php echo htmlspecialchars( $totp_qr ); ?>" alt="<?php echo htmlspecialchars(_('TOTP setup QR code')); ?>" width="220" height="220"></p>
|
<p><img src="<?php echo htmlspecialchars( $totp_qr ); ?>" alt="<?php echo htmlspecialchars(_('TOTP setup QR code')); ?>" width="220" height="220"></p>
|
||||||
<p><strong><?php echo htmlspecialchars($_SESSION[ 'user_totp_setup' ]); ?></strong></p>
|
<p><strong><?php echo htmlspecialchars($_SESSION[ 'user_totp_setup' ]); ?></strong></p>
|
||||||
<p><a href="<?php echo htmlspecialchars( $totp_uri ); ?>"><?php echo htmlspecialchars(_('Open authenticator setup link')); ?></a></p>
|
|
||||||
<form class="form_limit" action="manage_account.php" method="post">
|
<form class="form_limit" action="manage_account.php" method="post">
|
||||||
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION[ 'csrf_token' ]; ?>">
|
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION[ 'csrf_token' ]; ?>">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -439,8 +442,13 @@ if ( empty( $_SESSION[ 'email_user' ] ) ) { ?>
|
|||||||
</form>
|
</form>
|
||||||
<?php }
|
<?php }
|
||||||
if ( ! empty( $pgp_status[ 'pgp_key' ] ) ) {
|
if ( ! empty( $pgp_status[ 'pgp_key' ] ) ) {
|
||||||
if ( $pgp_status[ 'tfa' ] === 1 ) {
|
if ( (int) $pgp_status[ 'tfa' ] === 1 ) {
|
||||||
echo '<p class="green">'.htmlspecialchars(_('Yay, PGP based 2FA is enabled!')).'</p>';
|
?>
|
||||||
|
<form class="form_limit" action="manage_account.php" method="post">
|
||||||
|
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION[ 'csrf_token' ]; ?>">
|
||||||
|
<button type="submit" name="action" value="disable_pgp_2fa"><?php echo htmlspecialchars(_('Disable two-factor authentication')); ?></button>
|
||||||
|
</form>
|
||||||
|
<?php
|
||||||
} else {
|
} else {
|
||||||
$gpg = gnupg_init();
|
$gpg = gnupg_init();
|
||||||
gnupg_seterrormode( $gpg, GNUPG_ERROR_WARNING );
|
gnupg_seterrormode( $gpg, GNUPG_ERROR_WARNING );
|
||||||
|
|||||||
Reference in new issue
Block a user