Created
January 21, 2021 23:54
-
-
Save joelmiguelvalente/d8bd7d72d5cfafbb1dfa10fb8497eddd to your computer and use it in GitHub Desktop.
Para activar 2FA desde cuenta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ( ! defined('TS_HEADER')) exit('No se permite el acceso directo al script'); | |
/** | |
* Controlador AJAX | |
* | |
* @name ajax.cuenta.php | |
* @author Bastión | |
*/ | |
/**********************************\ | |
* (VARIABLES POR DEFAULT) * | |
\*********************************/ | |
// NIVELES DE ACCESO Y PLANTILLAS DE CADA ACCIÓN | |
$files = array( | |
'cuenta-dobleFactor' => array('n' => 2, 'p' => ''), | |
'cuenta-delete-fa' => array('n' => 2, 'p' => '') | |
); | |
/**********************************\ | |
* (VARIABLES LOCALES ESTE ARCHIVO) * | |
\*********************************/ | |
// REDEFINIR VARIABLES | |
$tsPage = 'php_files/p.cuenta.'.$files[$action]['p']; | |
$tsLevel = $files[$action]['n']; | |
$tsAjax = empty($files[$action]['p']) ? 1 : 0; | |
/**********************************\ | |
* (INSTRUCCIONES DE CODIGO) * | |
\*********************************/ | |
// DEPENDE EL NIVEL | |
$tsLevelMsg = $tsCore->setLevel($tsLevel, true); | |
if($tsLevelMsg != 1) { echo '0: '.$tsLevelMsg['mensaje']; die();} | |
include("../class/c.cuenta.php"); | |
$tsCuenta = new tsCuenta(); | |
switch($action) { | |
case 'cuenta-dobleFactor': | |
include TS_EXTRA . "GoogleAuthenticator/GoogleAuthenticatorInit.php"; | |
$g = new \Sonata\GoogleAuthenticator\GoogleAuthenticator(); | |
if($g->checkCode($_POST['secret'], $_POST['code'])) { | |
$tsCuenta->TwoFactor($_POST['secret'], $tsUser->uid); | |
echo '1: 2FA activado correctamente.'; | |
} else echo '0: Hubo un error!'; | |
break; | |
case 'cuenta-delete-fa': | |
echo $tsCuenta->delTwoFactor(); | |
break; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment