A free open source IT asset/license management system
Fixed #19620 - made avatar column wider
snipe142a3efe02e5
diff --git a/database/migrations/2026_10_19_164940_widen_users_avatar_column.php b/database/migrations/2026_10_19_164940_widen_users_avatar_column.phpnew file mode 100644index 0000000000..a5ff4e8c3b--- /dev/null+++ b/database/migrations/2026_10_19_164940_widen_users_avatar_column.php@@ -0,0 +1,30 @@+<?php++use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\Schema\Blueprint;+use Illuminate\Support\Facades\Schema;++return new class extends Migration+{+ /**+ * Widen users.avatar from varchar(191) to TEXT. SSO providers+ * (Google Workspace in particular) hand back avatar URLs that+ * exceed 191 characters, which MySQL in non-strict mode silently+ * truncates on write. The truncated URL then 400s on fetch and+ * renders as a broken image. The column isn't indexed, so no+ * key-length concern. Issue #19620.+ */+ public function up(): void+ {+ Schema::table('users', function (Blueprint $table) {+ $table->text('avatar')->nullable()->change();+ });+ }++ public function down(): void+ {+ Schema::table('users', function (Blueprint $table) {+ $table->string('avatar', 191)->nullable()->change();+ });+ }+};diff --git a/resources/views/blade/input/image-upload.blade.php b/resources/views/blade/input/image-upload.blade.phpindex 98b35bb703..574a7e7b37 100644--- a/resources/views/blade/input/image-upload.blade.php+++ b/resources/views/blade/input/image-upload.blade.php@@ -1,5 +1,6 @@@use('App\Helpers\Helper')@use('Illuminate\Support\Facades\Storage')+@use('Illuminate\Support\Str')@props(['item' => null,@@ -40,7 +41,11 @@{{-- Existing image thumbnail. Also no label column. --}}<div class="form-group" id="existing-image"><div class="col-md-8 col-md-offset-3">- <img src="{{ Storage::disk('public')->url($imagePath.e($existing_image)) }}" class="img-responsive" alt="">+ @if (Str::startsWith($existing_image, ['http://', 'https://']))+ <img src="{{ $existing_image }}" class="img-responsive" alt="">+ @else+ <img src="{{ Storage::disk('public')->url($imagePath.e($existing_image)) }}" class="img-responsive" alt="">+ @endif<x-form.error name="image_delete" /></div></div>diff --git a/resources/views/users/edit.blade.php b/resources/views/users/edit.blade.phpindex fdf84c3d5d..6d28061a8d 100755--- a/resources/views/users/edit.blade.php+++ b/resources/views/users/edit.blade.php@@ -271,7 +271,11 @@<x-form.row :label="trans('general.image_upload')" name="avatar"><x-slot:input>@if ($user->avatar)- <img src="{{ \Illuminate\Support\Facades\Storage::disk('public')->url(app('users_upload_path').e($user->avatar)) }}" class="img-responsive" alt="" style="max-width: 300px;">+ @if ($user->isAvatarExternal())+ <img src="{{ $user->avatar }}" class="img-responsive" alt="" style="max-width: 300px;">+ @else+ <img src="{{ \Illuminate\Support\Facades\Storage::disk('public')->url(app('users_upload_path').e($user->avatar)) }}" class="img-responsive" alt="" style="max-width: 300px;">+ @endif@endif<x-demo-lock :item="$user"/></x-slot:input>diff --git a/tests/Feature/Auth/GoogleLoginTest.php b/tests/Feature/Auth/GoogleLoginTest.phpindex d33c0239dc..8c2bd97a91 100644--- a/tests/Feature/Auth/GoogleLoginTest.php+++ b/tests/Feature/Auth/GoogleLoginTest.php@@ -39,6 +39,33 @@ class GoogleLoginTest extends TestCase$this->assertTrue(Auth::check(), 'User must be authenticated after a successful Google callback.');}+ #[Test]+ public function long_google_avatar_url_is_stored_intact(): void+ {+ // Regression test for issue #19620. Google Workspace avatar URLs+ // like `https://lh3.googleusercontent.com/a-/ALV-Uj...` routinely+ // run 260+ characters. The users.avatar column was previously+ // varchar(191), so MySQL in non-strict mode silently truncated+ // the stored URL, leaving a malformed token that 400s on fetch+ // and renders as a broken image.+ $user = User::factory()->create(['username' => '[email protected]']);++ $longUrl = 'https://lh3.googleusercontent.com/a-/'.str_repeat('ALV-Uj0123456789', 15).'=s96-c';+ $this->assertGreaterThan(191, strlen($longUrl));++ $socialUser = Mockery::mock(SocialiteUser::class);+ $socialUser->shouldReceive('getEmail')->andReturn('[email protected]');+ $socialUser->avatar = $longUrl;++ $driver = Mockery::mock();+ $driver->shouldReceive('user')->andReturn($socialUser);+ Socialite::shouldReceive('driver')->with('google')->andReturn($driver);++ $this->get(route('google.callback', ['code' => 'google-oauth-code']));++ $this->assertSame($longUrl, $user->fresh()->avatar);+ }+#[Test]public function callback_without_code_redirects_to_login_without_hitting_google(): void{