Skip to content

Commit f94cd2d

Browse files
committed
fix: getting identites does not work after calling createEmailIdentity()
1 parent 7cf6905 commit f94cd2d

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/Entities/User.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ public function createEmailIdentity(array $credentials): void
121121
$identityModel = model(UserIdentityModel::class);
122122

123123
$identityModel->createEmailIdentity($this, $credentials);
124+
125+
// Ensure we will reload all identities
126+
$this->identities = null;
124127
}
125128

126129
/**

tests/Unit/UserTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,18 @@ public function testUpdatePasswordHash(): void
216216
'secret2' => $hash,
217217
]);
218218
}
219+
220+
public function testCreateEmailIdentity(): void
221+
{
222+
$identity = $this->user->getEmailIdentity();
223+
$this->assertNull($identity);
224+
225+
$this->user->createEmailIdentity([
226+
'email' => 'foo@example.com',
227+
'password' => 'passbar',
228+
]);
229+
230+
$identity = $this->user->getEmailIdentity();
231+
$this->assertSame('foo@example.com', $identity->secret);
232+
}
219233
}

0 commit comments

Comments
 (0)