Skip to content

Commit 7fcdb97

Browse files
committed
feat: create users.email_verified_at if absent
1 parent 1a43294 commit 7fcdb97

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Auth/User.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public function generateVerificationToken($expiresIn = null): string
177177
*/
178178
public function isVerified(): bool
179179
{
180-
return !!$this->data['email_verified_at'];
180+
return !!($this->data['email_verified_at'] ?? false);
181181
}
182182

183183
/**
@@ -186,6 +186,14 @@ public function isVerified(): bool
186186
*/
187187
public function verifyEmail(): bool
188188
{
189+
if ($this->isVerified()) {
190+
return true;
191+
}
192+
193+
if (!isset($this->data['email_verified_at'])) {
194+
$this->db->query("ALTER TABLE " . Config::get('db.table') . " ADD COLUMN email_verified_at TIMESTAMP NULL DEFAULT NULL")->execute();
195+
}
196+
189197
$this->data['email_verified_at'] = tick()->format(Config::get('timestamps.format'));
190198

191199
try {

0 commit comments

Comments
 (0)