diff options
author | Andreas Gohr <andi@splitbrain.org> | 2015-05-07 09:42:30 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2015-05-07 09:42:30 +0200 |
commit | af865bf3762dff1ddfeb3bd15be46b605499a58b (patch) | |
tree | d5635fb24073ca01b733a66f29ae8f836ce51d1f /lib/plugins/authplain/auth.php | |
parent | 15e0e2356bfd266851932e1cde1287da7c5e201a (diff) | |
parent | e6c4392f11bb5a668be8e874560af910b71d72f8 (diff) | |
download | rpg-af865bf3762dff1ddfeb3bd15be46b605499a58b.tar.gz rpg-af865bf3762dff1ddfeb3bd15be46b605499a58b.tar.bz2 |
Merge pull request #1134 from ptbrown/auth-error-reporting
Refactor error messages from auth plugins.
Diffstat (limited to 'lib/plugins/authplain/auth.php')
-rw-r--r-- | lib/plugins/authplain/auth.php | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/lib/plugins/authplain/auth.php b/lib/plugins/authplain/auth.php index b31c02fc8..bd46c61a7 100644 --- a/lib/plugins/authplain/auth.php +++ b/lib/plugins/authplain/auth.php @@ -134,7 +134,10 @@ class auth_plugin_authplain extends DokuWiki_Auth_Plugin { global $config_cascade; // user mustn't already exist - if($this->getUserData($user) !== false) return false; + if($this->getUserData($user) !== false) { + msg($this->getLang('userexists'), -1); + return false; + } $pass = auth_cryptPassword($pwd); @@ -144,16 +147,13 @@ class auth_plugin_authplain extends DokuWiki_Auth_Plugin { // prepare user line $userline = $this->_createUserLine($user, $pass, $name, $mail, $grps); - if(io_saveFile($config_cascade['plainauth.users']['default'], $userline, true)) { - $this->users[$user] = compact('pass', 'name', 'mail', 'grps'); - return $pwd; + if(!io_saveFile($config_cascade['plainauth.users']['default'], $userline, true)) { + msg($this->getLang('writefail'), -1); + return null; } - msg( - 'The '.$config_cascade['plainauth.users']['default']. - ' file is not writable. Please inform the Wiki-Admin', -1 - ); - return null; + $this->users[$user] = compact('pass', 'name', 'mail', 'grps'); + return $pwd; } /** @@ -169,7 +169,10 @@ class auth_plugin_authplain extends DokuWiki_Auth_Plugin { global $config_cascade; // sanity checks, user must already exist and there must be something to change - if(($userinfo = $this->getUserData($user)) === false) return false; + if(($userinfo = $this->getUserData($user)) === false) { + msg($this->getLang('usernotexists'), -1); + return false; + } if(!is_array($changes) || !count($changes)) return true; // update userinfo with new data, remembering to encrypt any password @@ -186,13 +189,14 @@ class auth_plugin_authplain extends DokuWiki_Auth_Plugin { $userline = $this->_createUserLine($newuser, $userinfo['pass'], $userinfo['name'], $userinfo['mail'], $userinfo['grps']); if(!$this->deleteUsers(array($user))) { - msg('Unable to modify user data. Please inform the Wiki-Admin', -1); + msg($this->getLang('writefail'), -1); return false; } if(!io_saveFile($config_cascade['plainauth.users']['default'], $userline, true)) { msg('There was an error modifying your user data. You should register again.', -1); // FIXME, user has been deleted but not recreated, should force a logout and redirect to login page + // Should replace the delete/save hybrid modify with an atomic io_replaceInFile $ACT = 'register'; return false; } @@ -223,7 +227,10 @@ class auth_plugin_authplain extends DokuWiki_Auth_Plugin { if(empty($deleted)) return 0; $pattern = '/^('.join('|', $deleted).'):/'; - io_deleteFromFile($config_cascade['plainauth.users']['default'], $pattern, true); + if (!io_deleteFromFile($config_cascade['plainauth.users']['default'], $pattern, true)) { + msg($this->getLang('writefail'), -1); + return 0; + } // reload the user list and count the difference $count = count($this->users); @@ -407,4 +414,4 @@ class auth_plugin_authplain extends DokuWiki_Auth_Plugin { $this->_pattern[$item] = '/'.str_replace('/', '\/', $pattern).'/i'; // allow regex characters } } -}
\ No newline at end of file +} |