diff --git a/app/Livewire/RefreshAvatar.php b/app/Livewire/RefreshAvatar.php
new file mode 100644
index 000000000..d4ba094ec
--- /dev/null
+++ b/app/Livewire/RefreshAvatar.php
@@ -0,0 +1,58 @@
+user = $user;
+ }
+
+ public function refresh(): void
+ {
+ if (! $this->user->hasConnectedGitHubAccount()) {
+ $this->error('You need to connect your GitHub account to refresh your avatar.');
+
+ $this->redirectRoute('settings.profile');
+
+ return;
+ }
+
+ // Rate limiting: 1 request per 1 minute per user.
+ $key = 'avatar-refresh:'.$this->user->id();
+
+ if (RateLimiter::tooManyAttempts($key, 1)) {
+ $this->error('Please wait 1 minute before refreshing your avatar again.');
+
+ $this->redirectRoute('settings.profile');
+
+ return;
+ }
+
+ // Record this attempt for 1 minute.
+ RateLimiter::hit($key, 60);
+
+ UpdateUserIdenticonStatus::dispatchSync($this->user);
+
+ $this->success('Avatar refreshed successfully!');
+
+ $this->redirectRoute('settings.profile');
+ }
+
+ public function render(): View
+ {
+ return view('livewire.refresh-avatar');
+ }
+}
diff --git a/app/Models/User.php b/app/Models/User.php
index 87e841cfc..492675ee1 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -123,7 +123,7 @@ public function hasConnectedGitHubAccount(): bool
return ! is_null($this->githubId());
}
- public function hasIdenticon(): bool
+ public function hasGitHubIdenticon(): bool
{
return (bool) $this->github_has_identicon;
}
diff --git a/resources/views/components/avatar.blade.php b/resources/views/components/avatar.blade.php
index db261e951..9a7102758 100644
--- a/resources/views/components/avatar.blade.php
+++ b/resources/views/components/avatar.blade.php
@@ -1,26 +1,34 @@
@props([
'user',
'unlinked' => false,
+ 'showRefresh' => false,
])
githubId() && ! $user->hasIdenticon()
+$src = $user->githubId() && ! $user->hasGitHubIdenticon()
? sprintf('https://avatars.githubusercontent.com/u/%s', $user->githubId())
: asset('https://laravel.io/images/laravelio-icon-gray.svg');
?>
-@unless ($unlinked)
-
-@endunless
+