1: <?php
2:
3: namespace PHPixie\AuthLogin\Providers;
4:
5: class Password extends \PHPixie\Auth\Providers\Provider\Implementation
6: {
7: protected $passwordHandler;
8:
9: public function __construct($passwordHandler, $domain, $name, $configData)
10: {
11: parent::__construct($domain, $name, $configData);
12: $this->passwordHandler = $passwordHandler;
13: }
14:
15: public function hash($password)
16: {
17: return $this->passwordHandler->hash($password);
18: }
19:
20: public function login($login, $password)
21: {
22: $user = $this->repository()->getByLogin($login);
23:
24: if($user === null) {
25: return null;
26: }
27:
28: $hash = $user->passwordHash();
29: if(!$this->passwordHandler->verify($password, $hash)) {
30: return null;
31: }
32:
33: $this->domain->setUser($user, $this->name);
34:
35: $persistProviders = $this->configData->get('persistProviders', array());
36:
37: foreach($persistProviders as $providerName) {
38: $this->domain->provider($providerName)->persist();
39: }
40:
41: return $user;
42: }
43: }