Skip to content

Commit a9e8783

Browse files
committed
Merge pull request #1 from tshafer/master
Update for 5.2 Thank you.
2 parents e0beb3b + f8aa03a commit a9e8783

File tree

3 files changed

+46
-36
lines changed

3 files changed

+46
-36
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
],
1212
"require": {
1313
"php": ">=5.5.9",
14-
"illuminate/support": "5.0.*|5.1.*"
14+
"illuminate/support": "5.0.*|5.1.*|5.2.*"
1515
},
1616
"require-dev": {
1717
"phpunit/phpunit": "^4.7.6"

src/Traits/VerifiesUsers.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ public function getVerificationToken()
2727
/**
2828
* Handle the user verification.
2929
*
30-
* @param string $token
30+
* @param string $token
31+
*
3132
* @return Response
3233
*/
3334
public function getVerification($token)
@@ -38,7 +39,7 @@ public function getVerification($token)
3839
return redirect($this->redirectIfVerified());
3940
}
4041

41-
if ( ! UserVerification::process($user, $token)) {
42+
if (!UserVerification::process($user, $token)) {
4243
return redirect($this->redirectIfVerificationFails());
4344
}
4445

src/UserVerification.php

Lines changed: 42 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44

55
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
66
use Illuminate\Contracts\Mail\Mailer as MailerContract;
7-
use Illuminate\Mail\Message;
87
use Illuminate\Database\Schema\Builder;
98
use Illuminate\Support\Str;
10-
use Jrean\UserVerification\VerificationException;
119

1210
class UserVerification
1311
{
@@ -21,15 +19,15 @@ class UserVerification
2119
/**
2220
* Schema builder instance.
2321
*
24-
* @var \Illuminate\Database\Schema\Builder $schema
22+
* @var \Illuminate\Database\Schema\Builder
2523
*/
2624
protected $schema;
2725

2826
/**
2927
* Constructor.
3028
*
31-
* @param \Illuminate\Contracts\Mail\Mailer $mailer
32-
* @param \Illuminate\Database\Schema\Builder $schema
29+
* @param \Illuminate\Contracts\Mail\Mailer $mailer
30+
* @param \Illuminate\Database\Schema\Builder $schema
3331
*
3432
* @return void
3533
*/
@@ -43,8 +41,9 @@ public function __construct(MailerContract $mailer, Builder $schema)
4341
/**
4442
* Generate and save a verification token the given user.
4543
*
46-
* @param \Illuminate\Contracts\Auth\Authenticatable $model
47-
* @return boolean
44+
* @param \Illuminate\Contracts\Auth\Authenticatable $model
45+
*
46+
* @return bool
4847
*/
4948
public function generate(AuthenticatableContract $model)
5049
{
@@ -54,14 +53,15 @@ public function generate(AuthenticatableContract $model)
5453
/**
5554
* Send by email a link containing the verification token.
5655
*
57-
* @param \Illuminate\Contracts\Auth\Authenticatable $model
58-
* @param string $subject
59-
* @return boolean
56+
* @param \Illuminate\Contracts\Auth\Authenticatable $model
57+
* @param string $subject
58+
*
59+
* @return bool
6060
*/
6161
public function send(AuthenticatableContract $model, $subject = null)
6262
{
63-
if ( ! $this->isCompliant($model)) {
64-
throw new VerificationException;
63+
if (!$this->isCompliant($model)) {
64+
throw new VerificationException();
6565
}
6666

6767
return (boolean) $this->emailVerificationLink($model, $subject);
@@ -70,13 +70,14 @@ public function send(AuthenticatableContract $model, $subject = null)
7070
/**
7171
* Process the token verification.
7272
*
73-
* @param \Illuminate\Contracts\Auth\Authenticatable $model
74-
* @param string $token
75-
* @return boolean
73+
* @param \Illuminate\Contracts\Auth\Authenticatable $model
74+
* @param string $token
75+
*
76+
* @return bool
7677
*/
7778
public function process(AuthenticatableContract $model, $token)
7879
{
79-
if ( ! $this->compareToken($model->verification_token, $token)) {
80+
if (!$this->compareToken($model->verification_token, $token)) {
8081
return false;
8182
}
8283

@@ -88,8 +89,9 @@ public function process(AuthenticatableContract $model, $token)
8889
/**
8990
* Check if the user is verified.
9091
*
91-
* @param \Illuminate\Contracts\Auth\Authenticatable $model
92-
* @return boolean
92+
* @param \Illuminate\Contracts\Auth\Authenticatable $model
93+
*
94+
* @return bool
9395
*/
9496
public function isVerified(AuthenticatableContract $model)
9597
{
@@ -100,6 +102,7 @@ public function isVerified(AuthenticatableContract $model)
100102
* Update and save the model instance has verified.
101103
*
102104
* @param AuthenticatableContract $model
105+
*
103106
* @return void
104107
*/
105108
protected function wasVerified(AuthenticatableContract $model)
@@ -114,9 +117,10 @@ protected function wasVerified(AuthenticatableContract $model)
114117
/**
115118
* Compare the verification token given by the user with the one stored.
116119
*
117-
* @param string $storedToken
118-
* @param string $requestToken
119-
* @return boolean
120+
* @param string $storedToken
121+
* @param string $requestToken
122+
*
123+
* @return bool
120124
*/
121125
protected function compareToken($storedToken, $requestToken)
122126
{
@@ -126,8 +130,9 @@ protected function compareToken($storedToken, $requestToken)
126130
/**
127131
* Prepare and send the email with the verification token link.
128132
*
129-
* @param \Illuminate\Contracts\Auth\Authenticatable $model
130-
* @param string $subject
133+
* @param \Illuminate\Contracts\Auth\Authenticatable $model
134+
* @param string $subject
135+
*
131136
* @return mixed
132137
*/
133138
protected function emailVerificationLink(AuthenticatableContract $model, $subject)
@@ -152,15 +157,17 @@ protected function generateToken()
152157
/**
153158
* Update and save the model instance with the verification token.
154159
*
155-
* @param \Illuminate\Contracts\Auth\Authenticatable $model
156-
* @param string $token
157-
* @return boolean
160+
* @param \Illuminate\Contracts\Auth\Authenticatable $model
161+
* @param string $token
162+
*
158163
* @throws \Jrean\UserVerification\Exceptions\VerificationException
164+
*
165+
* @return bool
159166
*/
160167
protected function saveToken(AuthenticatableContract $model, $token)
161168
{
162-
if ( ! $this->isCompliant($model)) {
163-
throw new VerificationException;
169+
if (!$this->isCompliant($model)) {
170+
throw new VerificationException();
164171
}
165172

166173
$model->verification_token = $token;
@@ -172,8 +179,9 @@ protected function saveToken(AuthenticatableContract $model, $token)
172179
* Determine if the given model table has the verified and verification_token
173180
* columns.
174181
*
175-
* @param \Illuminate\Contracts\Auth\Authenticatable $model
176-
* @return boolean
182+
* @param \Illuminate\Contracts\Auth\Authenticatable $model
183+
*
184+
* @return bool
177185
*/
178186
protected function isCompliant(AuthenticatableContract $model)
179187
{
@@ -190,9 +198,10 @@ protected function isCompliant(AuthenticatableContract $model)
190198
/**
191199
* Check if the given model talbe has the given column.
192200
*
193-
* @param \Illuminate\Contracts\Auth\Authenticatable $model
194-
* @param string $column
195-
* @return boolean
201+
* @param \Illuminate\Contracts\Auth\Authenticatable $model
202+
* @param string $column
203+
*
204+
* @return bool
196205
*/
197206
protected function hasColumn(AuthenticatableContract $model, $column)
198207
{

0 commit comments

Comments
 (0)