BookStack
BookStack copied to clipboard
Download profile image on registration/login using OAuth2 / social logins
Describe the feature you'd like Currently a new user gets a random profile image instead of image being taken from the social login service. This should be easy to implement, basically a cosmetic change.
Describe the benefits this feature would bring to BookStack users Smoother UX. Profile automatically built from existing info using social login.
Additional context n/a
example code - tested with google login
// remote user
$user = Socialite::driver('google')->stateless()->redirectUrl(route('login.google.callback'))->with(['redirect_uri' => route('login.google.callback')])->user();
//generate image name
$whatever_image_name=trim(strtolower(str_replace(' ', '', iconv('UTF-8', 'ASCII//TRANSLIT', $user->getName()))));
// avatar image, replacing smaller size for larger size
$avatar = str_replace('sz=50', 'sz=200', $user->getAvatar());
// save image
Storage::put('users/' . $whatever_image_name, file_get_contents($avatar));
// set profile image for a local user
$local_user->image =$whatever_image_name;
- ref: https://github.com/BookStackApp/BookStack/pull/5429
- ref: https://github.com/BookStackApp/BookStack/pull/5626