passport-gitlab2
passport-gitlab2 copied to clipboard
User avatar is given in "avatarUrl" instead of "photos"
Unlike several other passport strategies (including passport-facebook, passport-github, and passport-twitter) that provide the user avatar in the profile object photos field, passport-gitlab2 uses avatarUrl instead.
Is there any reason for that? Would you accept a PR that change it?
I agree with previous post. Having the field with different name cause me troubles on NestJs AuthGuard validate function, I can extract it based on your naming, but If I try later to fetch it from the Request callback function, it has disappeared :'(
async validate(
_accessToken: string,
_refreshToken: string,
profile: Profile & { avatar_url: string },
) {
Logger.debug('GOOGLE', profile);
const { avatar_url, provider, displayName, username } = profile;
console.log('PROFILE', profile);
return {
accessToken: _accessToken,
provider: provider,
providerId: username,
name: displayName,
username: username,
photo: avatar_url,
};
}
Here , req.user.photo is empty ...
@UseGuards(AuthGuard('gitlab'))
@Get('callback')
async GitlabCallback(@Req() req: any, @Res() res: express.Response) {
const gitlabAccessToken = req.user.accessToken;
Logger.debug(
'Gitlab callback received user with GitlabAccessToken',
gitlabAccessToken,
req.user,
);
this.siwtService.gitlabPending.set(
gitlabAccessToken,
new UserProfile(
gitlabAccessToken,
req.user.name,
req.user.provider,
req.user.username,
req.user.photo,
),
);
```