Add comprehensive parameter debugging to find actual callback function in OIDC strategy
This commit is contained in:
@@ -79,15 +79,25 @@ function configureAuth(app) {
|
|||||||
scope: 'openid email profile',
|
scope: 'openid email profile',
|
||||||
skipUserProfile: false
|
skipUserProfile: false
|
||||||
}, (issuer, sub, profile, accessToken, refreshToken, done) => {
|
}, (issuer, sub, profile, accessToken, refreshToken, done) => {
|
||||||
console.log('OIDC Strategy callback:');
|
console.log('OIDC Strategy callback - All parameters:');
|
||||||
console.log('Issuer:', issuer);
|
console.log('Parameter 1 (issuer):', typeof issuer, issuer);
|
||||||
console.log('Subject:', sub);
|
console.log('Parameter 2 (sub):', typeof sub, sub);
|
||||||
console.log('Profile:', profile);
|
console.log('Parameter 3 (profile):', typeof profile, profile);
|
||||||
console.log('Access Token:', accessToken ? 'Present' : 'Missing');
|
console.log('Parameter 4 (accessToken):', typeof accessToken, accessToken);
|
||||||
console.log('Done callback type:', typeof done);
|
console.log('Parameter 5 (refreshToken):', typeof refreshToken, refreshToken);
|
||||||
|
console.log('Parameter 6 (done):', typeof done, done);
|
||||||
|
|
||||||
// Store the done callback to ensure it doesn't get lost
|
// Find the actual callback function - it might be in a different position
|
||||||
const strategyDone = done;
|
const args = Array.from(arguments);
|
||||||
|
console.log('All arguments:', args.map((arg, i) => `${i}: ${typeof arg}`));
|
||||||
|
|
||||||
|
const callback = args.find(arg => typeof arg === 'function');
|
||||||
|
console.log('Found callback function:', typeof callback);
|
||||||
|
|
||||||
|
if (!callback) {
|
||||||
|
console.error('No callback function found in arguments!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Extract user info from profile - sub is actually the profile object in this case
|
// Extract user info from profile - sub is actually the profile object in this case
|
||||||
console.log('Raw profile object:', JSON.stringify(sub, null, 2));
|
console.log('Raw profile object:', JSON.stringify(sub, null, 2));
|
||||||
@@ -101,13 +111,12 @@ function configureAuth(app) {
|
|||||||
console.log('Extracted user profile:', userProfile);
|
console.log('Extracted user profile:', userProfile);
|
||||||
|
|
||||||
userOps.findOrCreateUser(userProfile, (err, user) => {
|
userOps.findOrCreateUser(userProfile, (err, user) => {
|
||||||
console.log('Database callback - Done type:', typeof strategyDone);
|
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error('Database error in findOrCreateUser:', err);
|
console.error('Database error in findOrCreateUser:', err);
|
||||||
return strategyDone(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
console.log('User from database:', user);
|
console.log('User from database:', user);
|
||||||
strategyDone(null, user);
|
callback(null, user);
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user