Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/model/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class OAuthMeteorModel {
constructor (config = {}) {
const modelConfig = { ...DefaultModelConfig, ...config }
this.debug = modelConfig.debug
this.collections = collections
collections.AccessTokens = createCollection(modelConfig.accessTokensCollection, modelConfig.accessTokensCollectionName)
collections.RefreshTokens = createCollection(modelConfig.refreshTokensCollection, modelConfig.refreshTokensCollectionName)
collections.AuthCodes = createCollection(modelConfig.authCodesCollection, modelConfig.authCodesCollectionName)
Expand Down
19 changes: 19 additions & 0 deletions lib/oauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,25 @@ export class OAuth2Server {
}
}
}

/**
* Getter to access the underlying MongoDB collections for granular queries/indexing.
* Returns an object with: { AccessTokens, RefreshTokens, AuthCodes, Clients }.
* Do not mutate the collections directly—use the model's methods for OAuth compliance.
* @readonly
* @type {Object}
* @throws {Error} If model collections are not initialized.
* @example
* const server = new OAuth2Server(...);
* const accessTokens = server.collections.AccessTokens; // Mongo.Collection
* accessTokens.find({ "user.id": 'someUserId' }).fetch();
*/
get collections () {
if (!this.model || !this.model.collections) {
throw new Error('Model collections not initialized. Ensure model is properly configured.')
}
return Object.freeze({ ...this.model.collections })
}
}

const initRoutes = (self, {
Expand Down
Loading
Loading