View difference between Paste ID: MQVU8q9M and HcnJQuyT
SHOW: | | - or go back to the newest paste.
1
#
2
# SECURITY WARNING: it is CRITICAL that this file & directory are NOT accessible directly via a web browser!
3
#
4
# If you don't protect this directory from direct web access, anybody will be able to see your passwords.
5
# http://nette.org/security-warning
6
#
7
common:
8
	parameters:
9
		database:
10
			drive: mysql
11
			charset: utf8
12
			hostname: localhost
13
			username: root
14
			password: 123456
15
			database: prerost
16
			persistent: true
17
			lazy: true
18
19
20
	php:
21
		date.timezone: Europe/Prague
22
23
24
	services:
25-
		dibi: 
25+
		db: 
26
			class: DibiConnection(%database%)
27-
		
27+
28
		authenticator: Authenticator(@db)
29-
		authenticator: Authenticator( @dibi::table(users) )
29+
30
production < common:
31
32-
	factories:
32+
development < common:
33
34
35
36
37-
development < common:
37+
38
39
40
class Authenticator extends Nette\Object implements Nette\Security\IAuthenticator
41
{
42
	private $db;
43
	public function __construct(DibiConnection $db)
44
	{
45
		$this->db = $db
46
	}
47
48
	public function authenticate($credentials)
49
	{
50
		list($username, $password) = $credentials;
51
52
		$user = $this->db->select('*')->from('users')
53
			->where('username = %s', $username)->or('email = %s', $username);
54
55
		if (!$user) {
56
		// ...
57
	}
58
}