@@ -7,41 +7,41 @@ |
||
7 | 7 | */ |
8 | 8 | interface UserRepositoryInterface { |
9 | 9 | |
10 | - /** |
|
11 | - * Register a new user. |
|
12 | - * |
|
13 | - * @author Andrea Marco Sartori |
|
14 | - * @param array $attributes |
|
15 | - * @return mixed |
|
16 | - */ |
|
17 | - public function register(array $attributes); |
|
10 | + /** |
|
11 | + * Register a new user. |
|
12 | + * |
|
13 | + * @author Andrea Marco Sartori |
|
14 | + * @param array $attributes |
|
15 | + * @return mixed |
|
16 | + */ |
|
17 | + public function register(array $attributes); |
|
18 | 18 | |
19 | - /** |
|
20 | - * Assign a token to reset the password of the user with the given email. |
|
21 | - * |
|
22 | - * @author Andrea Marco Sartori |
|
23 | - * @param string $token |
|
24 | - * @param string $email |
|
25 | - * @return void |
|
26 | - */ |
|
27 | - public function assignResetToken($token, $email); |
|
19 | + /** |
|
20 | + * Assign a token to reset the password of the user with the given email. |
|
21 | + * |
|
22 | + * @author Andrea Marco Sartori |
|
23 | + * @param string $token |
|
24 | + * @param string $email |
|
25 | + * @return void |
|
26 | + */ |
|
27 | + public function assignResetToken($token, $email); |
|
28 | 28 | |
29 | - /** |
|
30 | - * Retrieve the user with the given reset token. |
|
31 | - * |
|
32 | - * @author Andrea Marco Sartori |
|
33 | - * @param string $token |
|
34 | - * @return mixed|null |
|
35 | - */ |
|
36 | - public function findByResetToken($token); |
|
29 | + /** |
|
30 | + * Retrieve the user with the given reset token. |
|
31 | + * |
|
32 | + * @author Andrea Marco Sartori |
|
33 | + * @param string $token |
|
34 | + * @return mixed|null |
|
35 | + */ |
|
36 | + public function findByResetToken($token); |
|
37 | 37 | |
38 | - /** |
|
39 | - * Reset the password of the given user. |
|
40 | - * |
|
41 | - * @author Andrea Marco Sartori |
|
42 | - * @param mixed $user |
|
43 | - * @return void |
|
44 | - */ |
|
45 | - public function resetPassword($user, $password); |
|
38 | + /** |
|
39 | + * Reset the password of the given user. |
|
40 | + * |
|
41 | + * @author Andrea Marco Sartori |
|
42 | + * @param mixed $user |
|
43 | + * @return void |
|
44 | + */ |
|
45 | + public function resetPassword($user, $password); |
|
46 | 46 | |
47 | 47 | } |
@@ -7,81 +7,81 @@ |
||
7 | 7 | */ |
8 | 8 | class EloquentUserRepository implements UserRepositoryInterface { |
9 | 9 | |
10 | - /** |
|
11 | - * @author Andrea Marco Sartori |
|
12 | - * @var User $user User model. |
|
13 | - */ |
|
14 | - protected $user; |
|
10 | + /** |
|
11 | + * @author Andrea Marco Sartori |
|
12 | + * @var User $user User model. |
|
13 | + */ |
|
14 | + protected $user; |
|
15 | 15 | |
16 | - /** |
|
17 | - * Set the dependencies. |
|
18 | - * |
|
19 | - * @author Andrea Marco Sartori |
|
20 | - * @return void |
|
21 | - */ |
|
22 | - public function __construct() |
|
23 | - { |
|
24 | - $user = config('auth.model'); |
|
16 | + /** |
|
17 | + * Set the dependencies. |
|
18 | + * |
|
19 | + * @author Andrea Marco Sartori |
|
20 | + * @return void |
|
21 | + */ |
|
22 | + public function __construct() |
|
23 | + { |
|
24 | + $user = config('auth.model'); |
|
25 | 25 | |
26 | - $this->user = new $user; |
|
27 | - } |
|
26 | + $this->user = new $user; |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * Register a new user. |
|
31 | - * |
|
32 | - * @author Andrea Marco Sartori |
|
33 | - * @param array $attributes |
|
34 | - * @return User |
|
35 | - */ |
|
36 | - public function register(array $attributes) |
|
37 | - { |
|
38 | - return $this->user->create($attributes); |
|
39 | - } |
|
29 | + /** |
|
30 | + * Register a new user. |
|
31 | + * |
|
32 | + * @author Andrea Marco Sartori |
|
33 | + * @param array $attributes |
|
34 | + * @return User |
|
35 | + */ |
|
36 | + public function register(array $attributes) |
|
37 | + { |
|
38 | + return $this->user->create($attributes); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Assign a token to reset the password of the user with the given email. |
|
43 | - * |
|
44 | - * @author Andrea Marco Sartori |
|
45 | - * @param string $token |
|
46 | - * @param string $email |
|
47 | - * @return void |
|
48 | - */ |
|
49 | - public function assignResetToken($token, $email) |
|
50 | - { |
|
51 | - $user = $this->user->whereEmail($email)->first(); |
|
41 | + /** |
|
42 | + * Assign a token to reset the password of the user with the given email. |
|
43 | + * |
|
44 | + * @author Andrea Marco Sartori |
|
45 | + * @param string $token |
|
46 | + * @param string $email |
|
47 | + * @return void |
|
48 | + */ |
|
49 | + public function assignResetToken($token, $email) |
|
50 | + { |
|
51 | + $user = $this->user->whereEmail($email)->first(); |
|
52 | 52 | |
53 | - $user->reset_token = $token; |
|
53 | + $user->reset_token = $token; |
|
54 | 54 | |
55 | - $user->save(); |
|
56 | - } |
|
55 | + $user->save(); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * Retrieve the user with the given reset token. |
|
60 | - * |
|
61 | - * @author Andrea Marco Sartori |
|
62 | - * @param string $token |
|
63 | - * @return User|null |
|
64 | - */ |
|
65 | - public function findByResetToken($token) |
|
66 | - { |
|
67 | - return $this->user->whereResetToken($token)->first(); |
|
68 | - } |
|
58 | + /** |
|
59 | + * Retrieve the user with the given reset token. |
|
60 | + * |
|
61 | + * @author Andrea Marco Sartori |
|
62 | + * @param string $token |
|
63 | + * @return User|null |
|
64 | + */ |
|
65 | + public function findByResetToken($token) |
|
66 | + { |
|
67 | + return $this->user->whereResetToken($token)->first(); |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * Reset the password of the given user. |
|
72 | - * |
|
73 | - * @author Andrea Marco Sartori |
|
74 | - * @param User $user |
|
75 | - * @param string $password |
|
76 | - * @return boolean |
|
77 | - */ |
|
78 | - public function resetPassword($user, $password) |
|
79 | - { |
|
80 | - $user->password = $password; |
|
70 | + /** |
|
71 | + * Reset the password of the given user. |
|
72 | + * |
|
73 | + * @author Andrea Marco Sartori |
|
74 | + * @param User $user |
|
75 | + * @param string $password |
|
76 | + * @return boolean |
|
77 | + */ |
|
78 | + public function resetPassword($user, $password) |
|
79 | + { |
|
80 | + $user->password = $password; |
|
81 | 81 | |
82 | - $user->reset_token = null; |
|
82 | + $user->reset_token = null; |
|
83 | 83 | |
84 | - $user->save(); |
|
85 | - } |
|
84 | + $user->save(); |
|
85 | + } |
|
86 | 86 | |
87 | 87 | } |
@@ -12,141 +12,141 @@ |
||
12 | 12 | class CachingThrottler implements ThrottlerInterface |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * @author Andrea Marco Sartori |
|
17 | - * @var Illuminate\Contracts\Cache\Repository $cache Cache repository. |
|
18 | - */ |
|
19 | - protected $cache; |
|
20 | - |
|
21 | - /** |
|
22 | - * @author Andrea Marco Sartori |
|
23 | - * @var string $key Source where attempts come from. |
|
24 | - */ |
|
25 | - protected $key; |
|
26 | - |
|
27 | - /** |
|
28 | - * @author Andrea Marco Sartori |
|
29 | - * @var string $lockOutKey Key to store lock out time in. |
|
30 | - */ |
|
31 | - protected $lockOutKey; |
|
15 | + /** |
|
16 | + * @author Andrea Marco Sartori |
|
17 | + * @var Illuminate\Contracts\Cache\Repository $cache Cache repository. |
|
18 | + */ |
|
19 | + protected $cache; |
|
20 | + |
|
21 | + /** |
|
22 | + * @author Andrea Marco Sartori |
|
23 | + * @var string $key Source where attempts come from. |
|
24 | + */ |
|
25 | + protected $key; |
|
26 | + |
|
27 | + /** |
|
28 | + * @author Andrea Marco Sartori |
|
29 | + * @var string $lockOutKey Key to store lock out time in. |
|
30 | + */ |
|
31 | + protected $lockOutKey; |
|
32 | 32 | |
33 | - /** |
|
34 | - * Set the dependencies. |
|
35 | - * |
|
36 | - * @author Andrea Marco Sartori |
|
37 | - * @param Illuminate\Contracts\Cache\Repository $cache |
|
38 | - * @return void |
|
39 | - */ |
|
40 | - public function __construct(Cache $cache) |
|
41 | - { |
|
42 | - $this->cache = $cache; |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * Set univocal source where attempts come from. |
|
47 | - * |
|
48 | - * @author Andrea Marco Sartori |
|
49 | - * @return boolean |
|
50 | - */ |
|
51 | - public function setSource($source) |
|
52 | - { |
|
53 | - $this->key = $source; |
|
54 | - |
|
55 | - $this->lockOutKey = "{$source}:lockout"; |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * Determine whether the user has been locked out. |
|
60 | - * |
|
61 | - * @author Andrea Marco Sartori |
|
62 | - * @return boolean |
|
63 | - */ |
|
64 | - public function lockedOut() |
|
65 | - { |
|
66 | - return $this->cache->has($this->lockOutKey); |
|
67 | - } |
|
68 | - |
|
69 | - /** |
|
70 | - * Retrieve the number of remaining seconds before the next attempt. |
|
71 | - * |
|
72 | - * @author Andrea Marco Sartori |
|
73 | - * @return integer |
|
74 | - */ |
|
75 | - public function getRemainingSeconds() |
|
76 | - { |
|
77 | - return $this->cache->get($this->lockOutKey) - time(); |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * Increment the number of failed attempts. |
|
82 | - * |
|
83 | - * @author Andrea Marco Sartori |
|
84 | - * @return void |
|
85 | - */ |
|
86 | - public function incrementAttempts() |
|
87 | - { |
|
88 | - $this->cache->add($this->key, 0, $this->getExpiry()); |
|
89 | - |
|
90 | - $this->cache->increment($this->key); |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * Retrieve the minutes after which keys expire. |
|
95 | - * |
|
96 | - * @author Andrea Marco Sartori |
|
97 | - * @return integer |
|
98 | - */ |
|
99 | - private function getExpiry() |
|
100 | - { |
|
101 | - return (int) $this->getDelay() / 60; |
|
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * Retrieve the seconds to wait before the next attempt. |
|
106 | - * |
|
107 | - * @author Andrea Marco Sartori |
|
108 | - * @return integer |
|
109 | - */ |
|
110 | - private function getDelay() |
|
111 | - { |
|
112 | - return config('_auth.login.throttling.delay'); |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * Determine whether a user has performed too many attempts. |
|
117 | - * |
|
118 | - * @author Andrea Marco Sartori |
|
119 | - * @return boolean |
|
120 | - */ |
|
121 | - public function tooManyAttempts() |
|
122 | - { |
|
123 | - $maximum = config('_auth.login.throttling.max_attempts'); |
|
124 | - |
|
125 | - return $this->cache->get($this->key, 0) > $maximum; |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * Lock a user out. |
|
130 | - * |
|
131 | - * @author Andrea Marco Sartori |
|
132 | - * @return void |
|
133 | - */ |
|
134 | - public function lockOut() |
|
135 | - { |
|
136 | - $this->resetAttempts(); |
|
137 | - |
|
138 | - $this->cache->add($this->lockOutKey, $this->getDelay() + time(), $this->getExpiry()); |
|
139 | - } |
|
140 | - |
|
141 | - /** |
|
142 | - * Reset the attempts counter. |
|
143 | - * |
|
144 | - * @author Andrea Marco Sartori |
|
145 | - * @return void |
|
146 | - */ |
|
147 | - public function resetAttempts() |
|
148 | - { |
|
149 | - $this->cache->forget($this->key); |
|
150 | - } |
|
33 | + /** |
|
34 | + * Set the dependencies. |
|
35 | + * |
|
36 | + * @author Andrea Marco Sartori |
|
37 | + * @param Illuminate\Contracts\Cache\Repository $cache |
|
38 | + * @return void |
|
39 | + */ |
|
40 | + public function __construct(Cache $cache) |
|
41 | + { |
|
42 | + $this->cache = $cache; |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * Set univocal source where attempts come from. |
|
47 | + * |
|
48 | + * @author Andrea Marco Sartori |
|
49 | + * @return boolean |
|
50 | + */ |
|
51 | + public function setSource($source) |
|
52 | + { |
|
53 | + $this->key = $source; |
|
54 | + |
|
55 | + $this->lockOutKey = "{$source}:lockout"; |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * Determine whether the user has been locked out. |
|
60 | + * |
|
61 | + * @author Andrea Marco Sartori |
|
62 | + * @return boolean |
|
63 | + */ |
|
64 | + public function lockedOut() |
|
65 | + { |
|
66 | + return $this->cache->has($this->lockOutKey); |
|
67 | + } |
|
68 | + |
|
69 | + /** |
|
70 | + * Retrieve the number of remaining seconds before the next attempt. |
|
71 | + * |
|
72 | + * @author Andrea Marco Sartori |
|
73 | + * @return integer |
|
74 | + */ |
|
75 | + public function getRemainingSeconds() |
|
76 | + { |
|
77 | + return $this->cache->get($this->lockOutKey) - time(); |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * Increment the number of failed attempts. |
|
82 | + * |
|
83 | + * @author Andrea Marco Sartori |
|
84 | + * @return void |
|
85 | + */ |
|
86 | + public function incrementAttempts() |
|
87 | + { |
|
88 | + $this->cache->add($this->key, 0, $this->getExpiry()); |
|
89 | + |
|
90 | + $this->cache->increment($this->key); |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * Retrieve the minutes after which keys expire. |
|
95 | + * |
|
96 | + * @author Andrea Marco Sartori |
|
97 | + * @return integer |
|
98 | + */ |
|
99 | + private function getExpiry() |
|
100 | + { |
|
101 | + return (int) $this->getDelay() / 60; |
|
102 | + } |
|
103 | + |
|
104 | + /** |
|
105 | + * Retrieve the seconds to wait before the next attempt. |
|
106 | + * |
|
107 | + * @author Andrea Marco Sartori |
|
108 | + * @return integer |
|
109 | + */ |
|
110 | + private function getDelay() |
|
111 | + { |
|
112 | + return config('_auth.login.throttling.delay'); |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * Determine whether a user has performed too many attempts. |
|
117 | + * |
|
118 | + * @author Andrea Marco Sartori |
|
119 | + * @return boolean |
|
120 | + */ |
|
121 | + public function tooManyAttempts() |
|
122 | + { |
|
123 | + $maximum = config('_auth.login.throttling.max_attempts'); |
|
124 | + |
|
125 | + return $this->cache->get($this->key, 0) > $maximum; |
|
126 | + } |
|
127 | + |
|
128 | + /** |
|
129 | + * Lock a user out. |
|
130 | + * |
|
131 | + * @author Andrea Marco Sartori |
|
132 | + * @return void |
|
133 | + */ |
|
134 | + public function lockOut() |
|
135 | + { |
|
136 | + $this->resetAttempts(); |
|
137 | + |
|
138 | + $this->cache->add($this->lockOutKey, $this->getDelay() + time(), $this->getExpiry()); |
|
139 | + } |
|
140 | + |
|
141 | + /** |
|
142 | + * Reset the attempts counter. |
|
143 | + * |
|
144 | + * @author Andrea Marco Sartori |
|
145 | + * @return void |
|
146 | + */ |
|
147 | + public function resetAttempts() |
|
148 | + { |
|
149 | + $this->cache->forget($this->key); |
|
150 | + } |
|
151 | 151 | |
152 | 152 | } |
@@ -10,60 +10,60 @@ |
||
10 | 10 | interface ThrottlerInterface |
11 | 11 | { |
12 | 12 | |
13 | - /** |
|
14 | - * Set univocal source where attempts come from. |
|
15 | - * |
|
16 | - * @author Andrea Marco Sartori |
|
17 | - * @return boolean |
|
18 | - */ |
|
19 | - public function setSource($source); |
|
13 | + /** |
|
14 | + * Set univocal source where attempts come from. |
|
15 | + * |
|
16 | + * @author Andrea Marco Sartori |
|
17 | + * @return boolean |
|
18 | + */ |
|
19 | + public function setSource($source); |
|
20 | 20 | |
21 | - /** |
|
22 | - * Determine whether the user has been locked out. |
|
23 | - * |
|
24 | - * @author Andrea Marco Sartori |
|
25 | - * @return boolean |
|
26 | - */ |
|
27 | - public function lockedOut(); |
|
21 | + /** |
|
22 | + * Determine whether the user has been locked out. |
|
23 | + * |
|
24 | + * @author Andrea Marco Sartori |
|
25 | + * @return boolean |
|
26 | + */ |
|
27 | + public function lockedOut(); |
|
28 | 28 | |
29 | - /** |
|
30 | - * Retrieve the number of remaining seconds before the next attempt. |
|
31 | - * |
|
32 | - * @author Andrea Marco Sartori |
|
33 | - * @return integer |
|
34 | - */ |
|
35 | - public function getRemainingSeconds(); |
|
29 | + /** |
|
30 | + * Retrieve the number of remaining seconds before the next attempt. |
|
31 | + * |
|
32 | + * @author Andrea Marco Sartori |
|
33 | + * @return integer |
|
34 | + */ |
|
35 | + public function getRemainingSeconds(); |
|
36 | 36 | |
37 | - /** |
|
38 | - * Increment the number of failed attempts. |
|
39 | - * |
|
40 | - * @author Andrea Marco Sartori |
|
41 | - * @return void |
|
42 | - */ |
|
43 | - public function incrementAttempts(); |
|
37 | + /** |
|
38 | + * Increment the number of failed attempts. |
|
39 | + * |
|
40 | + * @author Andrea Marco Sartori |
|
41 | + * @return void |
|
42 | + */ |
|
43 | + public function incrementAttempts(); |
|
44 | 44 | |
45 | - /** |
|
46 | - * Determine whether a user has performed too many attempts. |
|
47 | - * |
|
48 | - * @author Andrea Marco Sartori |
|
49 | - * @return boolean |
|
50 | - */ |
|
51 | - public function tooManyAttempts(); |
|
45 | + /** |
|
46 | + * Determine whether a user has performed too many attempts. |
|
47 | + * |
|
48 | + * @author Andrea Marco Sartori |
|
49 | + * @return boolean |
|
50 | + */ |
|
51 | + public function tooManyAttempts(); |
|
52 | 52 | |
53 | - /** |
|
54 | - * Lock a user out. |
|
55 | - * |
|
56 | - * @author Andrea Marco Sartori |
|
57 | - * @return void |
|
58 | - */ |
|
59 | - public function lockOut(); |
|
53 | + /** |
|
54 | + * Lock a user out. |
|
55 | + * |
|
56 | + * @author Andrea Marco Sartori |
|
57 | + * @return void |
|
58 | + */ |
|
59 | + public function lockOut(); |
|
60 | 60 | |
61 | - /** |
|
62 | - * Reset the attempts counter. |
|
63 | - * |
|
64 | - * @author Andrea Marco Sartori |
|
65 | - * @return void |
|
66 | - */ |
|
67 | - public function resetAttempts(); |
|
61 | + /** |
|
62 | + * Reset the attempts counter. |
|
63 | + * |
|
64 | + * @author Andrea Marco Sartori |
|
65 | + * @return void |
|
66 | + */ |
|
67 | + public function resetAttempts(); |
|
68 | 68 | |
69 | 69 | } |
@@ -6,65 +6,65 @@ |
||
6 | 6 | |
7 | 7 | class Throttle extends AbstractPipe { |
8 | 8 | |
9 | - /** |
|
10 | - * Run before the job is handled. |
|
11 | - * |
|
12 | - * @param Cerbero\Auth\Services\Throttling\ThrottlerInterface $throttler |
|
13 | - * @param Cerbero\Auth\Jobs\LoginJob $job |
|
14 | - * @return mixed |
|
15 | - */ |
|
16 | - public function before(ThrottlerInterface $throttler, $job) |
|
17 | - { |
|
18 | - $throttler->setSource($this->getSourceByJob($job)); |
|
9 | + /** |
|
10 | + * Run before the job is handled. |
|
11 | + * |
|
12 | + * @param Cerbero\Auth\Services\Throttling\ThrottlerInterface $throttler |
|
13 | + * @param Cerbero\Auth\Jobs\LoginJob $job |
|
14 | + * @return mixed |
|
15 | + */ |
|
16 | + public function before(ThrottlerInterface $throttler, $job) |
|
17 | + { |
|
18 | + $throttler->setSource($this->getSourceByJob($job)); |
|
19 | 19 | |
20 | - $throttler->incrementAttempts(); |
|
20 | + $throttler->incrementAttempts(); |
|
21 | 21 | |
22 | - if($throttler->tooManyAttempts() || $throttler->lockedOut()) |
|
23 | - { |
|
24 | - $throttler->lockOut(); |
|
22 | + if($throttler->tooManyAttempts() || $throttler->lockedOut()) |
|
23 | + { |
|
24 | + $throttler->lockOut(); |
|
25 | 25 | |
26 | - $seconds = $throttler->getRemainingSeconds(); |
|
26 | + $seconds = $throttler->getRemainingSeconds(); |
|
27 | 27 | |
28 | - throw new DisplayException('auth::throttling.error', compact('seconds')); |
|
29 | - } |
|
30 | - } |
|
28 | + throw new DisplayException('auth::throttling.error', compact('seconds')); |
|
29 | + } |
|
30 | + } |
|
31 | 31 | |
32 | - /** |
|
33 | - * Create source by using the given job. |
|
34 | - * |
|
35 | - * @author Andrea Marco Sartori |
|
36 | - * @param type $job |
|
37 | - * @return string |
|
38 | - */ |
|
39 | - private function getSourceByJob($job) |
|
40 | - { |
|
41 | - $login = head(array_except($job->credentials, 'password')); |
|
32 | + /** |
|
33 | + * Create source by using the given job. |
|
34 | + * |
|
35 | + * @author Andrea Marco Sartori |
|
36 | + * @param type $job |
|
37 | + * @return string |
|
38 | + */ |
|
39 | + private function getSourceByJob($job) |
|
40 | + { |
|
41 | + $login = head(array_except($job->credentials, 'password')); |
|
42 | 42 | |
43 | - return $login . app('request')->ip(); |
|
44 | - } |
|
43 | + return $login . app('request')->ip(); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Run after the handled job. |
|
48 | - * |
|
49 | - * @param Cerbero\Auth\Services\Throttling\ThrottlerInterface $throttler |
|
50 | - * @param mixed $handled |
|
51 | - * @param Cerbero\Auth\Jobs\LoginJob $job |
|
52 | - * @return mixed |
|
53 | - */ |
|
54 | - public function after(ThrottlerInterface $throttler, $handled, $job) |
|
55 | - { |
|
56 | - $throttler->resetAttempts(); |
|
57 | - } |
|
46 | + /** |
|
47 | + * Run after the handled job. |
|
48 | + * |
|
49 | + * @param Cerbero\Auth\Services\Throttling\ThrottlerInterface $throttler |
|
50 | + * @param mixed $handled |
|
51 | + * @param Cerbero\Auth\Jobs\LoginJob $job |
|
52 | + * @return mixed |
|
53 | + */ |
|
54 | + public function after(ThrottlerInterface $throttler, $handled, $job) |
|
55 | + { |
|
56 | + $throttler->resetAttempts(); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Determine whether the whole pipe has to be processed. |
|
61 | - * |
|
62 | - * @author Andrea Marco Sartori |
|
63 | - * @return boolean |
|
64 | - */ |
|
65 | - protected function isEnabled() |
|
66 | - { |
|
67 | - return config('_auth.login.throttling.enabled'); |
|
68 | - } |
|
59 | + /** |
|
60 | + * Determine whether the whole pipe has to be processed. |
|
61 | + * |
|
62 | + * @author Andrea Marco Sartori |
|
63 | + * @return boolean |
|
64 | + */ |
|
65 | + protected function isEnabled() |
|
66 | + { |
|
67 | + return config('_auth.login.throttling.enabled'); |
|
68 | + } |
|
69 | 69 | |
70 | 70 | } |
@@ -10,78 +10,78 @@ |
||
10 | 10 | */ |
11 | 11 | abstract class AbstractEventDispatcherPipe extends AbstractPipe { |
12 | 12 | |
13 | - /** |
|
14 | - * @author Andrea Marco Sartori |
|
15 | - * @var Illuminate\Contracts\Events\Dispatcher $dispatcher Event dispatcher. |
|
16 | - */ |
|
17 | - protected $dispatcher; |
|
13 | + /** |
|
14 | + * @author Andrea Marco Sartori |
|
15 | + * @var Illuminate\Contracts\Events\Dispatcher $dispatcher Event dispatcher. |
|
16 | + */ |
|
17 | + protected $dispatcher; |
|
18 | 18 | |
19 | - /** |
|
20 | - * Set the dependencies. |
|
21 | - * |
|
22 | - * @author Andrea Marco Sartori |
|
23 | - * @param Illuminate\Contracts\Container\Container $container |
|
24 | - * @param Illuminate\Contracts\Events\Dispatcher $dispatcher |
|
25 | - * @return void |
|
26 | - */ |
|
27 | - public function __construct(Container $container, Dispatcher $dispatcher) |
|
28 | - { |
|
29 | - parent::__construct($container); |
|
19 | + /** |
|
20 | + * Set the dependencies. |
|
21 | + * |
|
22 | + * @author Andrea Marco Sartori |
|
23 | + * @param Illuminate\Contracts\Container\Container $container |
|
24 | + * @param Illuminate\Contracts\Events\Dispatcher $dispatcher |
|
25 | + * @return void |
|
26 | + */ |
|
27 | + public function __construct(Container $container, Dispatcher $dispatcher) |
|
28 | + { |
|
29 | + parent::__construct($container); |
|
30 | 30 | |
31 | - $this->dispatcher = $dispatcher; |
|
32 | - } |
|
31 | + $this->dispatcher = $dispatcher; |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * Run before the job is handled. |
|
36 | - * |
|
37 | - * @param mixed $job |
|
38 | - * @return mixed |
|
39 | - */ |
|
40 | - public function before($job) |
|
41 | - { |
|
42 | - $this->fireEventOn('start', $job); |
|
43 | - } |
|
34 | + /** |
|
35 | + * Run before the job is handled. |
|
36 | + * |
|
37 | + * @param mixed $job |
|
38 | + * @return mixed |
|
39 | + */ |
|
40 | + public function before($job) |
|
41 | + { |
|
42 | + $this->fireEventOn('start', $job); |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Fire an event at some point. |
|
47 | - * |
|
48 | - * @author Andrea Marco Sartori |
|
49 | - * @param string $action |
|
50 | - * @param mixed $payload |
|
51 | - * @return void |
|
52 | - */ |
|
53 | - private function fireEventOn($action, $payload) |
|
54 | - { |
|
55 | - $event = $this->getEventName(); |
|
45 | + /** |
|
46 | + * Fire an event at some point. |
|
47 | + * |
|
48 | + * @author Andrea Marco Sartori |
|
49 | + * @param string $action |
|
50 | + * @param mixed $payload |
|
51 | + * @return void |
|
52 | + */ |
|
53 | + private function fireEventOn($action, $payload) |
|
54 | + { |
|
55 | + $event = $this->getEventName(); |
|
56 | 56 | |
57 | - $this->dispatcher->fire("auth.{$event}.{$action}", $payload); |
|
58 | - } |
|
57 | + $this->dispatcher->fire("auth.{$event}.{$action}", $payload); |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * Retrieve the event name. |
|
62 | - * |
|
63 | - * @author Andrea Marco Sartori |
|
64 | - * @return string |
|
65 | - */ |
|
66 | - protected function getEventName() |
|
67 | - { |
|
68 | - $chunks = explode('\\', get_class($this)); |
|
60 | + /** |
|
61 | + * Retrieve the event name. |
|
62 | + * |
|
63 | + * @author Andrea Marco Sartori |
|
64 | + * @return string |
|
65 | + */ |
|
66 | + protected function getEventName() |
|
67 | + { |
|
68 | + $chunks = explode('\\', get_class($this)); |
|
69 | 69 | |
70 | - $name = $chunks[count($chunks) - 2]; |
|
70 | + $name = $chunks[count($chunks) - 2]; |
|
71 | 71 | |
72 | - return strtolower($name); |
|
73 | - } |
|
72 | + return strtolower($name); |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * Run after the handled job. |
|
77 | - * |
|
78 | - * @param mixed $handled |
|
79 | - * @param mixed $job |
|
80 | - * @return mixed |
|
81 | - */ |
|
82 | - public function after($handled, $job) |
|
83 | - { |
|
84 | - $this->fireEventOn('end', [$handled, $job]); |
|
85 | - } |
|
75 | + /** |
|
76 | + * Run after the handled job. |
|
77 | + * |
|
78 | + * @param mixed $handled |
|
79 | + * @param mixed $job |
|
80 | + * @return mixed |
|
81 | + */ |
|
82 | + public function after($handled, $job) |
|
83 | + { |
|
84 | + $this->fireEventOn('end', [$handled, $job]); |
|
85 | + } |
|
86 | 86 | |
87 | 87 | } |
@@ -5,17 +5,17 @@ |
||
5 | 5 | |
6 | 6 | class Store extends AbstractPipe { |
7 | 7 | |
8 | - /** |
|
9 | - * Run after the handled job. |
|
10 | - * |
|
11 | - * @param Cerbero\Auth\Repositories\UserRepositoryInterface $user |
|
12 | - * @param mixed $handled |
|
13 | - * @param Cerbero\Auth\Jobs\RecoverJob $job |
|
14 | - * @return mixed |
|
15 | - */ |
|
16 | - public function after(UserRepositoryInterface $user, $handled, $job) |
|
17 | - { |
|
18 | - $user->assignResetToken($handled, $job->email); |
|
19 | - } |
|
8 | + /** |
|
9 | + * Run after the handled job. |
|
10 | + * |
|
11 | + * @param Cerbero\Auth\Repositories\UserRepositoryInterface $user |
|
12 | + * @param mixed $handled |
|
13 | + * @param Cerbero\Auth\Jobs\RecoverJob $job |
|
14 | + * @return mixed |
|
15 | + */ |
|
16 | + public function after(UserRepositoryInterface $user, $handled, $job) |
|
17 | + { |
|
18 | + $user->assignResetToken($handled, $job->email); |
|
19 | + } |
|
20 | 20 | |
21 | 21 | } |
@@ -5,24 +5,24 @@ |
||
5 | 5 | |
6 | 6 | class Notify extends AbstractPipe { |
7 | 7 | |
8 | - /** |
|
9 | - * Run after the handled job. |
|
10 | - * |
|
11 | - * @param Illuminate\Contracts\Mail\Mailer $mailer |
|
12 | - * @param mixed $handled |
|
13 | - * @param Cerbero\Auth\Jobs\RecoverJob $job |
|
14 | - * @return mixed |
|
15 | - */ |
|
16 | - public function after(Mailer $mailer, $handled, $job) |
|
17 | - { |
|
18 | - $email = $job->email; |
|
8 | + /** |
|
9 | + * Run after the handled job. |
|
10 | + * |
|
11 | + * @param Illuminate\Contracts\Mail\Mailer $mailer |
|
12 | + * @param mixed $handled |
|
13 | + * @param Cerbero\Auth\Jobs\RecoverJob $job |
|
14 | + * @return mixed |
|
15 | + */ |
|
16 | + public function after(Mailer $mailer, $handled, $job) |
|
17 | + { |
|
18 | + $email = $job->email; |
|
19 | 19 | |
20 | - $method = config('_auth.recover.email.queue') ? 'queue' : 'send'; |
|
20 | + $method = config('_auth.recover.email.queue') ? 'queue' : 'send'; |
|
21 | 21 | |
22 | - $mailer->$method(config('_auth.recover.email.view'), ['token' => $handled], function($message) use($email) |
|
23 | - { |
|
24 | - $message->to($email)->subject(trans('auth::recover.email_subject')); |
|
25 | - }); |
|
26 | - } |
|
22 | + $mailer->$method(config('_auth.recover.email.view'), ['token' => $handled], function($message) use($email) |
|
23 | + { |
|
24 | + $message->to($email)->subject(trans('auth::recover.email_subject')); |
|
25 | + }); |
|
26 | + } |
|
27 | 27 | |
28 | 28 | } |
@@ -5,28 +5,28 @@ |
||
5 | 5 | |
6 | 6 | class Login extends AbstractPipe { |
7 | 7 | |
8 | - /** |
|
9 | - * Run after the handled job. |
|
10 | - * |
|
11 | - * @param Illuminate\Contracts\Auth\Guard $auth |
|
12 | - * @param mixed $handled |
|
13 | - * @param Cerbero\Auth\Jobs\LoginJob $job |
|
14 | - * @return mixed |
|
15 | - */ |
|
16 | - public function after(Guard $auth, $handled, $job) |
|
17 | - { |
|
18 | - $auth->login($handled); |
|
19 | - } |
|
8 | + /** |
|
9 | + * Run after the handled job. |
|
10 | + * |
|
11 | + * @param Illuminate\Contracts\Auth\Guard $auth |
|
12 | + * @param mixed $handled |
|
13 | + * @param Cerbero\Auth\Jobs\LoginJob $job |
|
14 | + * @return mixed |
|
15 | + */ |
|
16 | + public function after(Guard $auth, $handled, $job) |
|
17 | + { |
|
18 | + $auth->login($handled); |
|
19 | + } |
|
20 | 20 | |
21 | - /** |
|
22 | - * Determine whether the after method has to be processed. |
|
23 | - * |
|
24 | - * @author Andrea Marco Sartori |
|
25 | - * @return boolean |
|
26 | - */ |
|
27 | - protected function afterIsEnabled() |
|
28 | - { |
|
29 | - return config('_auth.register.login_after_registering'); |
|
30 | - } |
|
21 | + /** |
|
22 | + * Determine whether the after method has to be processed. |
|
23 | + * |
|
24 | + * @author Andrea Marco Sartori |
|
25 | + * @return boolean |
|
26 | + */ |
|
27 | + protected function afterIsEnabled() |
|
28 | + { |
|
29 | + return config('_auth.register.login_after_registering'); |
|
30 | + } |
|
31 | 31 | |
32 | 32 | } |