예제 #1
0
$l = OC_L10N::get('settings');
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('user_otp');
OCP\JSON::callCheck();
if ($_POST && $_POST["uid"] && OC_User::isAdminUser(OCP\User::getUser())) {
    OC_JSON::checkSubAdminUser();
    $uid = $_POST["uid"];
} else {
    $uid = OCP\User::getUser();
}
// Get data
$mOtp = new MultiOtpDb(OCP\Config::getAppValue('user_otp', 'EncryptionKey', 'DefaultCliEncryptionKey'));
$mOtp->EnableVerboseLog();
//$mOtp->SetDisplayLogOption(1);
if ($_POST && $_POST["otp_action"] === "delete_otp" && $mOtp->CheckUserExists($uid)) {
    if ($mOtp->DeleteUser($uid)) {
        OCP\JSON::success(array("data" => array("message" => $l->t("OTP Changed"))));
    } else {
        OCP\JSON::error(array("data" => array("message" => $l->t("check apps folder rights"))));
    }
} else {
    if ($_POST && $_POST["otp_action"] === "send_email_otp" && $mOtp->CheckUserExists($uid)) {
        $mOtp->SetUser($uid);
        if (OCP\Config::getAppValue('user_otp', 'TokenBase32Encode', true)) {
            $UserTokenSeed = base32_encode(hex2bin($mOtp->GetUserTokenSeed()));
            //$tmpl->assign('TokenBase32Encode',true);
        } else {
            $UserTokenSeed = hex2bin($mOtp->GetUserTokenSeed());
        }
        $key = 'email';
        $mail = "";