Skip to content

Commit

Permalink
[FEATURE] Added Yubikey field to user settings
Browse files Browse the repository at this point in the history
Closes #10
  • Loading branch information
derhansen committed Sep 10, 2017
1 parent 20cdab7 commit 4a46e9b
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
46 changes: 46 additions & 0 deletions Classes/Hooks/UserSettings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
namespace DERHANSEN\SfYubikey\Hooks;

/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/


/**
* User Settings class
*/
class UserSettings
{

/**
* Returns a textarea with the YubiKey IDs
*
* @return string
*/
public function user_yubikeyId()
{
$html = '<textarea id="field_tx_sfyubikey_yubikey_id" name="data[be_users][tx_sfyubikey_yubikey_id]"
rows="5" class="form-control t3js-formengine-textarea formengine-textarea">' .
htmlspecialchars($GLOBALS['BE_USER']->user['tx_sfyubikey_yubikey_id']) . '</textarea>';
return $html;
}

/**
* Returns the current BE user.
*
* @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
*/
protected function getBackendUser()
{
return $GLOBALS['BE_USER'];
}
}
2 changes: 1 addition & 1 deletion Configuration/TCA/Overrides/be_users.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
'be_users',
'--div--;YubiKey,tx_sfyubikey_yubikey_enable;;;;1-1-1, tx_sfyubikey_yubikey_id'
'--div--;YubiKey,tx_sfyubikey_yubikey_enable, tx_sfyubikey_yubikey_id'
);
18 changes: 18 additions & 0 deletions ext_tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,21 @@

// Add css file for YubiKey backend login
$TBE_STYLES['stylesheet2'] = '../typo3conf/ext/sf_yubikey/Resources/Public/Css/sf_yubikey.css';

// Add YubiKey fields to user settings
$GLOBALS['TYPO3_USER_SETTINGS']['columns']['tx_sfyubikey_yubikey_enable'] = [
'label' => 'LLL:EXT:sf_yubikey/Resources/Private/Language/locallang_db.xlf:users.tx_sfyubikey_yubikey_enable',
'type' => 'check',
'table' => 'be_users'
];

$GLOBALS['TYPO3_USER_SETTINGS']['columns']['tx_sfyubikey_yubikey_id'] = [
'label' => 'LLL:EXT:sf_yubikey/Resources/Private/Language/locallang_db.xlf:users.tx_sfyubikey_yubikey_id',
'type' => 'user',
'userFunc' => \DERHANSEN\SfYubikey\Hooks\UserSettings::class . '->user_yubikeyId',
'table' => 'be_users'
];

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToUserSettings(
'--div--;YubiKey,tx_sfyubikey_yubikey_enable, tx_sfyubikey_yubikey_id'
);

0 comments on commit 4a46e9b

Please sign in to comment.