Ejemplo n.º 1
0
    $name = $displayName;
    if ($displayName !== $uid) {
        $name = $name . ' (' . $uid . ')';
    }
    $UserTokenSeed = "";
    $UserLocked = "";
    $UserAlgorithm = "";
    $UserPin = "";
    $UserPrefixPin = "";
    //get otp information :
    $OtpExist = $mOtp->CheckUserExists($uid);
    if ($OtpExist) {
        $mOtp->SetUser($uid);
        $UserTokenSeed = base32_encode(hex2bin($mOtp->GetUserTokenSeed()));
        $UserLocked = $mOtp->GetUserLocked();
        $UserAlgorithm = $mOtp->GetUserAlgorithm();
        $UserPin = $mOtp->GetUserPin();
        $UserPrefixPin = $mOtp->GetUserPrefixPin();
    }
    $users[] = array("name" => $uid, "displayName" => $displayName, "groups" => OC_Group::getUserGroups($uid), 'subadmin' => OC_SubAdmin::getSubAdminsGroups($uid), 'OtpExist' => $OtpExist, 'UserTokenSeed' => $UserTokenSeed, 'UserLocked' => $UserLocked, 'UserAlgorithm' => $UserAlgorithm, 'UserPin' => $UserPin, 'UserPrefixPin' => $UserPrefixPin);
}
foreach ($accessiblegroups as $i) {
    // Do some more work here soon
    $groups[] = array("name" => $i);
}
$tmpl = new OC_Template("user_otp", "list_users", "user");
$tmpl->assign('PrefixPin', OCP\Config::getAppValue('user_otp', 'UserPrefixPin', '0') ? 1 : 0);
$tmpl->assign('users', $users);
$tmpl->assign('groups', $groups);
$tmpl->assign('isadmin', (int) $isadmin);
$tmpl->assign('subadmins', $subadmins);
Ejemplo n.º 2
0
     $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>';
 $txtmsg .= '<p>find your OTP Configuration<br>';
 $txtmsg .= 'User Algorithm : ' . $mOtp->GetUserAlgorithm() . '<br>';
 if ($mOtp->GetUserPrefixPin()) {
     $txtmsg .= 'User Pin : ' . $mOtp->GetUserPin() . '<br>';
 }
 $txtmsg .= 'User Token Seed : ' . $UserTokenSeed . "<br>";
 $txtmsg .= 'User Token Time Interval Or Last Event : ' . (strtolower($mOtp->GetUserAlgorithm()) === 'htop' ? $mOtp->GetUserTokenLastEvent() : $mOtp->GetUserTokenTimeInterval()) . "<br>";
 $txtmsg .= 'Token Url Link : ' . $mOtp->GetUserTokenUrlLink() . "<br>";
 $txtmsg .= 'With android token apps select base32 before input seed<br>';
 $txtmsg .= '<img src="data:image/png;base64,' . base64_encode($mOtp->GetUserTokenQrCode($mOtp->GetUser(), '', 'binary')) . '"/><br><br>';
 $txtmsg .= $l->t('<p>This e-mail is automatic, please, do not reply to it.</p></html>');
 if ($mail !== NULL) {
     try {
         $result = OC_Mail::send($mail, $uid, '[' . getenv('SERVER_NAME') . "] - OTP", $txtmsg, 'Mail_Notification@' . getenv('SERVER_NAME'), 'Owncloud', 1);
         OCP\JSON::success(array("data" => array("message" => $l->t("email sent to " . $mail))));
     } catch (Exception $e) {
         OCP\JSON::error(array("data" => array("message" => $l->t($e->getMessage()))));
Ejemplo n.º 3
0
//~ $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());
} else {
    $tmpl->assign('UserExists', false);
    $tmpl->assign('UserPrefixPin', OCP\Config::getAppValue('user_otp', 'UserPrefixPin', '0'));
}
return $tmpl->fetchPage();