Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support avatars being external URL or being base64-encoded #1299

Open
richardhj opened this issue Jan 24, 2025 · 0 comments
Open

Support avatars being external URL or being base64-encoded #1299

richardhj opened this issue Jan 24, 2025 · 0 comments

Comments

@richardhj
Copy link

richardhj commented Jan 24, 2025

From what it looks like, the user blueprint MUST have field "avatar" and this field MUST be of type asset. This approach does not work when working with external authentication providers.

https://github.com/statamic/cms/blob/85265e6e987ec2c5f1566fdd01b22f2d7a3ad89d/src/Auth/HasAvatar.php#L17

I am using the Socialite provider "microsoft" and this provider returns the avatar base64-encoded. This value is just ignored by Statamic, even using data:image/png;base64, XXX as a value does not work. The provider could also return a full URI.

How to reproduce
# /users/[email protected]
name: 'Foo'
avatar: '/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAA'

AppServiceProvider.php

// AppServiceProvider.php

Event::listen(function (SocialiteWasCalled $event) {
      $event->extendSocialite('microsoft', MicrosoftProvider::class);
  });

OAuth::provider('microsoft')
    ->withUserData(fn (SocialiteUser $socialiteUser, StatamicUser $statamicUser) => [
        'name' => $socialiteUser->getName(),
        'avatar' => $socialiteUser['avatar'],
    ]);
// services.php

return [
    'microsoft' => [
        // ...
        'include_avatar' => true,
    ],
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant