DEV Community

Discussion on: How to Implement Login with Google in Nest JS

Collapse
 
egormkn profile image
Egor Makarenko • Edited

@imichaelowolabi, done callback should not be used in validate method, because it is invoked internally by nestjs/passport. It is better to just return user object from validate:

async validate (accessToken: string, refreshToken: string, profile: any): Promise<any> {
    const { name, emails, photos } = profile
    const user = {
      email: emails[0].value,
      firstName: name.givenName,
      lastName: name.familyName,
      picture: photos[0].value,
      accessToken
    }
    return user;
}
Enter fullscreen mode Exit fullscreen mode