You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I created a class that inherits from one of the predefined Passport strategy (OAuth2 from passport-oauth) to be able to add some specific code. I ran into an issue with the context (this) that is set in the userProfile() method (call by the internal passport logic to create the user's profile)
Is there a workaround to be able to get / pass-on a reference of my GenericOAuth2Strategy ?
Thanks in advance
--- My code (simplified) ---
function GenericOAuth2Strategy(name, options, verify) {
// do something
this._name = "my name";
OAuth2Strategy.call(this, options, verify);
}
require('util').inherits(GenericOAuth2Strategy, OAuth2Strategy);
GenericOAuth2Strategy.prototype.myFunction() {
// In here this is not equal to my current GenericOAuth2Strategy
console.log(this);
console.log(this._name); // => this throw an error see below
console.log(this.getName()); // => this throw an error see below
}
GenericOAuth2Strategy.prototype.userProfile = function(accessToken, done) {
this.myVar = 'toto';
this.myFunction(); // this is called
}
I created a class that inherits from one of the predefined Passport strategy (OAuth2 from passport-oauth) to be able to add some specific code. I ran into an issue with the context (this) that is set in the userProfile() method (call by the internal passport logic to create the user's profile)
Is there a workaround to be able to get / pass-on a reference of my GenericOAuth2Strategy ?
Thanks in advance
--- My code (simplified) ---
--- Console output ---
When I try to access 'this._name' I get this error
When I try to access 'this.getName()' I get this error
The text was updated successfully, but these errors were encountered: