Ticket #556 (closed Feature Request: fixed)

Opened 7 months ago

Last modified 5 months ago

user exists by id, email or username

Reported by: littfed Owned by: Shadowhand
Priority: minor Milestone: 2.2
Component: Modules:Auth Version: SVN HEAD
Keywords: user exists Cc:

Description

I use Auth module, but I need function, to check if user exists in database not only by username.

I patch /models/user.php and add function exists.

	/**
	 * Tests if a user exists in the database.
	 *
	 * @param   string   username or email or id to check
	 * @return  bool
	 */
	public function exists($id)
	{
		if ( ! empty($id) AND is_string($id) AND ! ctype_digit($id))
		{
			$where = valid::email($id) ? 'email' : 'username';
		} else  $where = 'id';

		return (bool) self::$db->where($where, $id)->count_records('users');
	}

Maybe, it will be interesting for someone else?

Change History

Changed 7 months ago by JAAulde

  • milestone changed from 2.1.2 to 2.2

This is being considered, but am moving it to 2.2 as it is a feature request and not a bug fix.

Changed 5 months ago by Shadowhand

  • owner changed from - No owner - to Shadowhand
  • status changed from new to assigned

Fixed in r3000.

Changed 5 months ago by Shadowhand

  • status changed from assigned to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.