|
|
|
@ -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({
|
|
|
|
|