11import { InternalOAuthError , Strategy } from "passport-oauth2" ;
22import config from "../../config" ;
33
4- export function parseProfile ( data ) {
4+ export function parseProfile ( data ) {
55 const username = extractProfileAttribute ( data , config . oauth2 . userProfileUsernameAttr )
66 const displayName = extractProfileAttribute ( data , config . oauth2 . userProfileDisplayNameAttr )
77 const email = extractProfileAttribute ( data , config . oauth2 . userProfileEmailAttr )
@@ -20,7 +20,7 @@ export function parseProfile (data) {
2020 }
2121}
2222
23- export function extractProfileAttribute ( data , path ) {
23+ export function extractProfileAttribute ( data , path ) {
2424 if ( ! data ) return undefined
2525 if ( typeof path !== 'string' ) return undefined
2626 // can handle stuff like `attrs[0].name`
@@ -41,15 +41,16 @@ export function extractProfileAttribute (data, path) {
4141
4242export class OAuth2CustomStrategy extends Strategy {
4343 private _userProfileURL : any ;
44- constructor ( options , verify ) {
44+
45+ constructor ( options , verify ) {
4546 options . customHeaders = options . customHeaders || { }
4647 super ( options , verify )
4748 this . name = 'oauth2'
4849 this . _userProfileURL = options . userProfileURL
4950 this . _oauth2 . useAuthorizationHeaderforGET ( true )
5051 }
5152
52- userProfile ( accessToken , done ) {
53+ userProfile ( accessToken , done ) {
5354 this . _oauth2 . get ( this . _userProfileURL , accessToken , function ( err , body , res ) {
5455 if ( err ) {
5556 return done ( new InternalOAuthError ( 'Failed to fetch user profile' , err ) )
0 commit comments