Skip to content

Commit

Permalink
Revert "Coding style"
Browse files Browse the repository at this point in the history
This reverts commit c37d2ff.
  • Loading branch information
pief committed Sep 20, 2023
1 parent 138bb36 commit e1eeb11
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 27 deletions.
13 changes: 4 additions & 9 deletions action.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
*/

// must be run within Dokuwiki
if (!defined('DOKU_INC'))
die();
if(!defined('DOKU_INC')) die();

use dokuwiki\Extension\ActionPlugin;

Expand All @@ -49,22 +48,18 @@ public function __construct() {
DokuWiki has no capability setting for 'login', so we need a
little hack that pretends the admin disabled the login action
himself. */
$disableactions = explode(',', $this->getConf('disableactions'));
$disableactions = explode(',', $conf['disableactions']);
$disableactions = array_map('trim', $disableactions);
if (!in_array('login', $disableactions)) {
$disableactions[] = 'login';
}

/* Fortunately DokuWiki gained a proper API that allows programmatic
access to getting config values. Unfortunately it doesn't have
one to set them (for good reason), so we need to hack agian... */
$GLOBALS['conf']['disableactions'] = implode(',', $disableactions);
$conf['disableactions'] = implode(',', $disableactions);

/* We also don't want DokuWiki to generate passwords on its own and
mail them to the users upon registration. We need to use the same
hack as above, pretending the admin disabled password generation
himself. */
$GLOBALS['conf']['autopasswd'] = 0;
$conf['autopasswd'] = 0;
}
}

Expand Down
24 changes: 6 additions & 18 deletions auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
*/

// must be run within Dokuwiki
if (!defined('DOKU_INC'))
die();
if(!defined('DOKU_INC')) die();

use dokuwiki\Extension\AuthPlugin;

Expand All @@ -44,20 +43,10 @@ public function __construct() {

parent::__construct();

/* We have to distinguish between the plugin being loaded and the plugin
actually being used for authentication. */
$this->active = (
$conf['authtype'] == 'authhttp' ||
(
$conf['authtype'] == 'authsplit' &&
$conf['plugin']['authsplit']['primary_authplugin'] == 'authhttp'
)
);

/* Make sure that HTTP authentication has been enabled in the Web
server. Note that does not seem to work with PHP >= 4.3.0 and safe
mode enabled! */
if (!array_key_exists('PHP_AUTH_USER', $_SERVER) || $_SERVER['PHP_AUTH_USER'] == "") {
if ($_SERVER['PHP_AUTH_USER'] == "") {
msg($this->getLang('nocreds'), -1);
$this->success = false;
return;
Expand All @@ -77,7 +66,7 @@ public function __construct() {
$this->loadConfig();

/* Set the config values */
foreach (array('usernameregex', 'emaildomain', 'specialusers', 'specialgroup') as $cfgvar) {
foreach (array("usernameregex", "emaildomain", "specialusers", "specialgroup") as $cfgvar) {
$this->$cfgvar = $this->getConf("$cfgvar");
if (!$this->$cfgvar) {
msg("Config error: \"$cfgvar\" not set!", -1);
Expand All @@ -94,9 +83,6 @@ public function __construct() {
/* No support for logout in this auth plugin. */
$this->cando['logout'] = false;
}

/* Initialization was successful */
$this->success = true;
}

/**
Expand Down Expand Up @@ -125,9 +111,11 @@ public function checkPass($user, $pass) {
* @return array containing user data or false
*/
public function getUserData($user, $requireGroups = true) {
global $conf;

$info['name'] = $user;
$info['mail'] = $user."@".$this->emaildomain;
$info['grps'] = array($this->getConf('defaultgroup'));
$info['grps'] = array($conf['defaultgroup']);
if (in_array($user, $this->specialusers)) {
$info['grps'][] = $this->specialgroup;
}
Expand Down

0 comments on commit e1eeb11

Please sign in to comment.