예제 #1
0
} 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 = "";
        $query = OC_DB::prepare('SELECT `configvalue` FROM `*PREFIX*preferences` WHERE `configkey` = ? AND `userid`=?');
        $result = $query->execute(array($key, $uid));
        if (!OC_DB::isError($result)) {
            $row = $result->fetchRow();
            $mail = $row['configvalue'];
        }
        $txtmsg = '<html><p>Hi, ' . $uid . ', <br><br>';
예제 #2
0
 *
 */
OCP\Util::addscript('user_otp', 'personalSettings');
$mOtp = new MultiOtpDb(OCP\Config::getAppValue('user_otp', 'EncryptionKey', 'DefaultCliEncryptionKey'));
$mOtp->EnableVerboseLog();
//~ $mOtp->SetUsersFolder(
//~ OCP\Config::getAppValue(
//~ 'user_otp','UsersFolder',
//~ getcwd()."/apps/user_otp/3rdparty/multiotp/users/"
//~ )
//~ );
$tmpl = new OCP\Template('user_otp', 'personalSettings');
$tmpl->assign('disableDeleteOtpForUsers', OCP\Config::getAppValue('user_otp', 'disableDeleteOtpForUsers', '0'));
if ($mOtp->CheckUserExists(OCP\User::getUser())) {
    $tmpl->assign('UserExists', true);
    $mOtp->SetUser(OCP\User::getUser());
    $img = \OCP\Util::linkToRoute('user_otp_qrcode');
    $tmpl->assign('UserTokenUrlLink', $mOtp->GetUserTokenUrlLink());
    $tmpl->assign('UserTokenQrCode', $img);
    //~ if(OCP\Config::getAppValue('user_otp','TokenBase32Encode',true)){
    //~ $tmpl->assign('UserTokenSeed',base32_encode(hex2bin($mOtp->GetUserTokenSeed())));
    //~ $tmpl->assign('TokenBase32Encode',true);
    //~ }else{
    //~ $tmpl->assign('UserTokenSeed',hex2bin($mOtp->GetUserTokenSeed()));
    //~ }
    $tmpl->assign('UserTokenSeed', base32_encode(hex2bin($mOtp->GetUserTokenSeed())));
    $tmpl->assign('UserPin', $mOtp->GetUserPin());
    $tmpl->assign('UserPrefixPin', $mOtp->GetUserPrefixPin());
    $tmpl->assign('UserLocked', $mOtp->GetUserLocked());
    $tmpl->assign('UserAlgorithm', $mOtp->GetUserAlgorithm());
    $tmpl->assign('UserTokenTimeIntervalOrLastEvent', strtolower($mOtp->GetUserAlgorithm()) === 'htop' ? $mOtp->GetUserTokenLastEvent() : $mOtp->GetUserTokenTimeInterval());