Lines Matching +full:update +full:- +full:user +full:- +full:pass -(+path:inc +path:lang) -(+path:lib +path:plugins +path:lang) -(+path:lib +path:tpl +path:dokuwiki +path:lang)

13  * @author     Jan Schumann <js@schumann-it.com>
17 /** @var array user cache */
40 $this->success = false;
43 $this->cando['addUser'] = true;
44 $this->cando['delUser'] = true;
45 $this->cando['modLogin'] = true;
46 $this->cando['modPass'] = true;
47 $this->cando['modName'] = true;
48 $this->cando['modMail'] = true;
49 $this->cando['modGroups'] = true;
51 $this->cando['getUsers'] = true;
52 $this->cando['getUserCount'] = true;
53 $this->cando['getGroups'] = true;
58 * Check user+password
60 * Checks if the given user exists and the given
64 * @param string $user
65 * @param string $pass
68 public function checkPass($user, $pass)
70 $userinfo = $this->getUserData($user);
73 return auth_verifyPassword($pass, $this->users[$user]['pass']);
77 * Return user info
79 * Returns info about the given user needs to contain
82 * name string full name of the user
83 * mail string email addres of the user
84 * grps array list of groups the user is in
87 * @param string $user
91 public function getUserData($user, $requireGroups = true)
93 if ($this->users === null) $this->loadUserData();
94 return $this->users[$user] ?? false;
102 * @param string $user
103 * @param string $pass
106 * @param array $grps list of groups the user is in
109 protected function createUserLine($user, $pass, $name, $mail, $grps)
112 $userline = [$user, $pass, $name, $mail, $groups];
121 * Create a new User
123 * Returns false if the user already exists, null when an error
126 * The new user will be added to the default group by this
132 * @param string $user
139 public function createUser($user, $pwd, $name, $mail, $grps = null)
144 // user mustn't already exist
145 if ($this->getUserData($user) !== false) {
146 msg($this->getLang('userexists'), -1);
150 $pass = auth_cryptPassword($pwd);
155 // prepare user line
156 $userline = $this->createUserLine($user, $pass, $name, $mail, $grps);
159 msg($this->getLang('writefail'), -1);
163 $this->users[$user] = [
164 'pass' => $pass,
173 * Modify user data
176 * @param string $user nick of the user to be changed
180 public function modifyUser($user, $changes)
185 // sanity checks, user must already exist and there must be something to change
186 if (($userinfo = $this->getUserData($user)) === false) {
187 msg($this->getLang('usernotexists'), -1);
193 msg(sprintf($this->getLang('protected'), hsc($user)), -1);
199 // update userinfo with new data, remembering to encrypt any password
200 $newuser = $user;
202 if ($field == 'user') {
206 if ($field == 'pass') $value = auth_cryptPassword($value);
210 $userline = $this->createUserLine(
212 $userinfo['pass'],
218 if (!io_replaceInFile($config_cascade['plainauth.users']['default'], '/^' . $user . ':/', $userline, true)) {
219 msg('There was an error modifying your user data. You may need to register again.', -1);
220 // FIXME, io functions should be fail-safe so existing data isn't lost
225 if (isset($this->users[$user])) unset($this->users[$user]);
226 $this->users[$newuser] = $userinfo;
243 if ($this->users === null) $this->loadUserData();
246 foreach ($users as $user) {
248 if (!empty($this->users[$user]['protected'])) {
249 msg(sprintf($this->getLang('protected'), hsc($user)), -1);
252 if (isset($this->users[$user])) $deleted[] = preg_quote($user, '/');
259 msg($this->getLang('writefail'), -1);
263 // reload the user list and count the difference
264 $count = count($this->users);
265 $this->loadUserData();
266 $count -= count($this->users);
271 * Return a count of the number of user which meet $filter criteria
281 if ($this->users === null) $this->loadUserData();
283 if ($filter === []) return count($this->users);
286 $this->constructPattern($filter);
288 foreach ($this->users as $user => $info) {
289 $count += $this->filter($user, $info);
296 * Bulk retrieval of user data
300 * @param int $start index of first user to be returned
308 if ($this->users === null) $this->loadUserData();
310 Sort::ksort($this->users);
315 $this->constructPattern($filter);
317 foreach ($this->users as $user => $info) {
318 if ($this->filter($user, $info)) {
320 $out[$user] = $info;
333 * Loads complete user data into memory before searching for groups.
343 if ($this->users === null) $this->loadUserData();
344 foreach ($this->users as $info) {
358 * @param string $user
361 public function cleanUser($user)
365 return cleanID(str_replace([':', '/', ';'], $conf['sepchar'], $user));
382 * Load all user data
384 * loads the user file into a datastructure
392 $this->users = $this->readUserFile($config_cascade['plainauth.users']['default']);
396 $protected = $this->readUserFile($config_cascade['plainauth.users']['protected']);
400 $this->users = array_merge($this->users, $protected);
405 * Read user data from given file
423 $row = $this->splitUserData($line);
430 $users[$row[0]]['pass'] = $row[1];
439 * Get the user line split into it's parts
449 Logger::error('User line with less than 5 fields. Possibly corruption in your user file', $data);
455 * return true if $user + $info match $filter criteria, false otherwise
459 * @param string $user User login
460 * @param array $info User's userinfo array
463 protected function filter($user, $info)
465 foreach ($this->pattern as $item => $pattern) {
466 if ($item == 'user') {
467 if (!preg_match($pattern, $user)) return false;
484 $this->pattern = [];
486 $this->pattern[$item] = '/' . str_replace('/', '\/', $pattern) . '/i'; // allow regex characters