From b124d266d6705d5a9050654a73ab8ad3df2d1406 Mon Sep 17 00:00:00 2001 From: rob Date: Tue, 5 Jul 2022 17:25:25 -0400 Subject: [PATCH] more OAuth2 progress --- app/services/oauth2.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/services/oauth2.js b/app/services/oauth2.js index e75c310..1b83f5f 100644 --- a/app/services/oauth2.js +++ b/app/services/oauth2.js @@ -72,17 +72,17 @@ class OAuth2Service extends SiteService { } async serializeClient (client, done) { - this.log.debug('serializeClient', { client }); - return done(null, client.id); + this.log.debug('serializeClient', { clientID: client._id.toString() }); + return done(null, client._id.toString()); } - async deserializeClient (clientId, done) { - this.log.debug('deserializeClient', { clientId }); + async deserializeClient (clientID, done) { + this.log.debug('deserializeClient', { clientID }); try { const client = await OAuth2Client - .findOne({ _id: clientId }) + .findOne({ _id: clientID }) .lean(); - this.log.debug('OAuth2 client loaded', { clientId }); + this.log.debug('OAuth2 client loaded', { clientID }); return done(null, client); } catch (error) { this.log.error('failed to deserialize OAuth2 client', { clientId, error }); @@ -170,8 +170,10 @@ class OAuth2Service extends SiteService { async issueTokens (authCode) { const response = { + accessToken: generatePassword(256, false), + refreshToken: generatePassword(256, false), params: { - coreUserId: authCode.user._id, + coreUserId: authCode.user._id.toString(), username: authCode.user.username, username_lc: authCode.user.username_lc, displayName: authCode.user.displayName, @@ -179,8 +181,6 @@ class OAuth2Service extends SiteService { permissions: authCode.user.permissions, flags: authCode.user.flags, }, - accessToken: generatePassword(256, false), - refreshToken: generatePassword(256, false), }; await Promise.all([ OAuth2Token.create({