@@ -47,6 +47,10 @@ public function __construct(Mailer $mailer, Builder $schema)
47
47
{
48
48
$ this ->mailer = $ mailer ;
49
49
$ this ->schema = $ schema ;
50
+
51
+ if (! $ this ->isCompliant ()) {
52
+ throw new ModelNotCompliantException ();
53
+ }
50
54
}
51
55
52
56
/**
@@ -85,10 +89,6 @@ protected function generateToken()
85
89
*/
86
90
protected function saveToken (AuthenticatableContract $ user , $ token )
87
91
{
88
- if (! $ this ->isCompliant ($ user )) {
89
- throw new ModelNotCompliantException ();
90
- }
91
-
92
92
$ user ->verified = false ;
93
93
94
94
$ user ->verification_token = $ token ;
@@ -114,10 +114,6 @@ public function send(
114
114
$ name = null
115
115
)
116
116
{
117
- if (! $ this ->isCompliant ($ user )) {
118
- throw new ModelNotCompliantException ();
119
- }
120
-
121
117
$ this ->emailVerificationLink ($ user , $ subject , $ from , $ name );
122
118
123
119
event (new VerificationEmailSent ($ user ));
@@ -141,10 +137,6 @@ public function sendQueue(
141
137
$ name = null
142
138
)
143
139
{
144
- if (! $ this ->isCompliant ($ user )) {
145
- throw new ModelNotCompliantException ();
146
- }
147
-
148
140
$ this ->emailQueueVerificationLink ($ user , $ subject , $ from , $ name );
149
141
150
142
event (new VerificationEmailSent ($ user ));
@@ -170,10 +162,6 @@ public function sendLater(
170
162
$ name = null
171
163
)
172
164
{
173
- if (! $ this ->isCompliant ($ user )) {
174
- throw new ModelNotCompliantException ();
175
- }
176
-
177
165
$ this ->emailLaterVerificationLink ($ delay , $ user , $ subject , $ from , $ name );
178
166
179
167
event (new VerificationEmailSent ($ user ));
@@ -259,7 +247,7 @@ public function process($email, $token, $userTable)
259
247
unset($ user ->{"password " });
260
248
261
249
// Check if the given user is already verified.
262
- // If he is, we stop here.
250
+ // If it is, we stop here.
263
251
$ this ->isVerified ($ user );
264
252
265
253
$ this ->verifyToken ($ user ->verification_token , $ token );
@@ -361,26 +349,12 @@ protected function updateUser($user)
361
349
* Determine if the given model table has the verified and verification_token
362
350
* columns.
363
351
*
364
- * @param \Illuminate\Contracts\Auth\Authenticatable $user
365
352
* @return bool
366
353
*/
367
- protected function isCompliant (AuthenticatableContract $ user )
354
+ protected function isCompliant ()
368
355
{
369
- return $ this ->hasColumn ($ user , 'verified ' )
370
- && $ this ->hasColumn ($ user , 'verification_token ' )
371
- ? true
372
- : false ;
373
- }
356
+ $ user = config ('auth.providers.users.model ' , App \User::class);
374
357
375
- /**
376
- * Check if the given model talbe has the given column.
377
- *
378
- * @param \Illuminate\Contracts\Auth\Authenticatable $user
379
- * @param string $column
380
- * @return bool
381
- */
382
- protected function hasColumn (AuthenticatableContract $ user , $ column )
383
- {
384
- return $ this ->schema ->hasColumn ($ user ->getTable (), $ column );
358
+ return $ this ->schema ->hasColumns ((new $ user ())->getTable (), ['verified ' , 'verification_token ' ])? true : false ;
385
359
}
386
360
}
0 commit comments