Skip to content
Snippets Groups Projects
Commit db9faf02 authored by Patrick Brown's avatar Patrick Brown
Browse files

Report more meaningful errors when an auth backend fails. closes #1093

parent dfe7cc3f
No related branches found
No related tags found
No related merge requests found
Showing
with 139 additions and 25 deletions
......@@ -1006,7 +1006,7 @@ function register() {
//okay try to create the user
if(!$auth->triggerUserMod('create', array($login, $pass, $fullname, $email))) {
msg($lang['reguexists'], -1);
msg($lang['regfail'], -1);
return false;
}
......@@ -1098,17 +1098,18 @@ function updateprofile() {
}
}
if($result = $auth->triggerUserMod('modify', array($INPUT->server->str('REMOTE_USER'), &$changes))) {
// update cookie and session with the changed data
if($changes['pass']) {
list( /*user*/, $sticky, /*pass*/) = auth_getCookie();
$pass = auth_encrypt($changes['pass'], auth_cookiesalt(!$sticky, true));
auth_setCookie($INPUT->server->str('REMOTE_USER'), $pass, (bool) $sticky);
}
return true;
if(!($result = $auth->triggerUserMod('modify', array($INPUT->server->str('REMOTE_USER'), &$changes)))) {
msg($lang['proffail'], -1);
return false;
}
return false;
// update cookie and session with the changed data
if($changes['pass']) {
list( /*user*/, $sticky, /*pass*/) = auth_getCookie();
$pass = auth_encrypt($changes['pass'], auth_cookiesalt(!$sticky, true));
auth_setCookie($INPUT->server->str('REMOTE_USER'), $pass, (bool) $sticky);
}
return true;
}
/**
......@@ -1221,7 +1222,7 @@ function act_resendpwd() {
// change it
if(!$auth->triggerUserMod('modify', array($user, array('pass' => $pass)))) {
msg('error modifying user data', -1);
msg($lang['proffail'], -1);
return false;
}
......@@ -1229,7 +1230,7 @@ function act_resendpwd() {
$pass = auth_pwgen($user);
if(!$auth->triggerUserMod('modify', array($user, array('pass' => $pass)))) {
msg('error modifying user data', -1);
msg($lang['proffail'], -1);
return false;
}
......
......@@ -75,6 +75,7 @@ $lang['regmissing'] = 'Sorry, you must fill in all fields.';
$lang['reguexists'] = 'Sorry, a user with this login already exists.';
$lang['regsuccess'] = 'The user has been created and the password was sent by email.';
$lang['regsuccess2'] = 'The user has been created.';
$lang['regfail'] = 'The user could not be created.';
$lang['regmailfail'] = 'Looks like there was an error on sending the password mail. Please contact the admin!';
$lang['regbadmail'] = 'The given email address looks invalid - if you think this is an error, contact the admin';
$lang['regbadpass'] = 'The two given passwords are not identical, please try again.';
......@@ -90,6 +91,7 @@ $lang['profdeleteuser'] = 'Delete Account';
$lang['profdeleted'] = 'Your user account has been deleted from this wiki';
$lang['profconfdelete'] = 'I wish to remove my account from this wiki. <br/> This action can not be undone.';
$lang['profconfdeletemissing'] = 'Confirmation check box not ticked';
$lang['proffail'] = 'User profile was not updated.';
$lang['pwdforget'] = 'Forgotten your password? Get a new one';
$lang['resendna'] = 'This wiki does not support password resending.';
......
......@@ -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
}
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
*/
$lang['userexists'] = 'Die gebruikersnaam wat jy gebruik het, is alreeds gebruik. Kies asseblief \'n ander gebruikersnaam.';
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
*/
$lang['userexists'] = 'عذرا، يوجد مشترك بنفس الاسم.';
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
*/
$lang['userexists'] = 'Təssüf ki bu ad ilə istifadəçi artıq mövcuddur.';
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
*/
$lang['userexists'] = 'Вече съществува потребител с избраното име.';
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
*/
$lang['userexists'] = 'দুঃখিত, এই লগইন সঙ্গে একটি ব্যবহারকারী ইতিমধ্যেই বিদ্যমান.';
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
*/
$lang['userexists'] = 'Disculpe, pero ya existix un usuari en este nom.';
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
*/
$lang['userexists'] = 'Ja existeix un altre usuari amb aquest nom.';
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
*/
$lang['userexists'] = 'Uživatel se stejným jménem už je zaregistrován.';
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
*/
$lang['userexists'] = 'Dette brugernavn er allerede i brug.';
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
*/
$lang['userexists'] = 'Der Benutzername existiert leider schon.';
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
*/
$lang['userexists'] = 'Der Benutzername existiert leider schon.';
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
*/
$lang['userexists'] = 'Αυτός ο λογαριασμός υπάρχει ήδη.';
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
*/
$lang['userexists'] = 'Sorry, a user with this login already exists.';
$lang['usernotexists'] = 'Sorry, that user doesn\'t exist.';
$lang['writefail'] = 'Unable to modify user data. Please inform the Wiki-Admin';
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
*/
$lang['userexists'] = 'Pardonu, ĉi tiu uzanto-nomo jam ekzistas.';
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
*/
$lang['userexists'] = 'Lo siento, ya existe un usuario con este nombre.';
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
*/
$lang['userexists'] = 'Tegelikult on sellise nimega kasutaja juba olemas.';
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
*/
$lang['userexists'] = 'Barkatu, izen bereko erabiltzailea existitzen da.';
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment