Lines Matching defs:user
17 /** @var array user cache */
58 * Check user+password
60 * Checks if the given user exists and the given
64 * @param string $user
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)
94 return $this->users[$user] ?? false;
102 * @param string $user
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];
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) {
155 // prepare user line
156 $userline = $this->createUserLine($user, $pass, $name, $mail, $grps);
163 $this->users[$user] = [
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) {
193 msg(sprintf($this->getLang('protected'), hsc($user)), -1);
200 $newuser = $user;
202 if ($field == 'user') {
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);
225 if (isset($this->users[$user])) unset($this->users[$user]);
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, '/');
263 // reload the user list and count the difference
271 * Return a count of the number of user which meet $filter criteria
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
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.
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
405 * Read user data from given file
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
463 protected function filter($user, $info)
466 if ($item == 'user') {
467 if (!preg_match($pattern, $user)) return false;