Skip to content

Commit

Permalink
Merge branch '5.0' into 5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
lcharette committed Feb 26, 2024
2 parents 0e1dcea + b4b28a9 commit 84aeed0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Update to PHPUnit 10
- Test against MariaDB [#1238](https://github.com/userfrosting/UserFrosting/issues/1238)

## [5.0.3](https://github.com/userfrosting/sprinkle-account/compare/5.0.2...5.0.3)
- Fix exception thrown when empty user is serialized ([userfrosting/sprinkle-account#15](https://github.com/userfrosting/sprinkle-account/pull/15))

## [5.0.2](https://github.com/userfrosting/sprinkle-account/compare/5.0.1...5.0.2)
- Fix issue with `has_role` access condition

Expand Down
3 changes: 2 additions & 1 deletion app/src/Database/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ public function getFullNameAttribute(): string
*/
public function getAvatarAttribute(): string
{
$hash = md5(strtolower(trim($this->email)));
$email = $this->email ?? '';
$hash = md5(strtolower(trim($email)));

return 'https://www.gravatar.com/avatar/' . $hash . '?d=mm';
}
Expand Down
13 changes: 13 additions & 0 deletions app/tests/Database/Models/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,19 @@ public function testUserAvatar(): void
$this->assertStringContainsString('gravatar', $user->avatar);
}

/**
* @see https://github.com/userfrosting/sprinkle-account/pull/15
*/
public function testUserAvatarForEmptyEmail(): void
{
/** @var User */
$user = new User();
$data = $user->toArray();

$this->assertArrayNotHasKey('email', $data);
$this->assertSame('https://www.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e?d=mm', $data['avatar']);
}

/**
* Test user hard deletion.
*/
Expand Down

0 comments on commit 84aeed0

Please sign in to comment.