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
8 changes: 4 additions & 4 deletions examples/mongodb/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ var Schema = mongoose.Schema;

mongoose.model('OAuthTokens', new Schema({
accessToken: { type: String },
accessTokenExpiresOn: { type: Date },
accessTokenExpiresAt: { type: Date },
client : { type: Object }, // `client` and `user` are required in multiple places, for example `getAccessToken()`
clientId: { type: String },
refreshToken: { type: String },
refreshTokenExpiresOn: { type: Date },
refreshTokenExpiresAt: { type: Date },
user : { type: Object },
userId: { type: String },
}));
Expand Down Expand Up @@ -79,11 +79,11 @@ module.exports.getUser = function(username, password) {
module.exports.saveToken = function(token, client, user) {
var accessToken = new OAuthTokensModel({
accessToken: token.accessToken,
accessTokenExpiresOn: token.accessTokenExpiresOn,
accessTokenExpiresAt: token.accessTokenExpiresAt,
client : client,
clientId: client.clientId,
refreshToken: token.refreshToken,
refreshTokenExpiresOn: token.refreshTokenExpiresOn,
refreshTokenExpiresAt: token.refreshTokenExpiresAt,
user : user,
userId: user._id,
});
Expand Down
4 changes: 2 additions & 2 deletions examples/postgresql/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ module.exports.getUser = function *(username, password) {
module.exports.saveAccessToken = function *(token, client, user) {
return pg.query('INSERT INTO oauth_tokens(access_token, access_token_expires_on, client_id, refresh_token, refresh_token_expires_on, user_id) VALUES ($1, $2, $3, $4)', [
token.accessToken,
token.accessTokenExpiresOn,
token.accessTokenExpiresAt,
client.id,
token.refreshToken,
token.refreshTokenExpiresOn,
token.refreshTokenExpiresAt,
user.id
]).then(function(result) {
return result.rowCount ? result.rows[0] : false; // TODO return object with client: {id: clientId} and user: {id: userId} defined
Expand Down
4 changes: 2 additions & 2 deletions examples/redis/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports.getAccessToken = function(bearerToken) {
return {
accessToken: token.accessToken,
clientId: token.clientId,
expires: token.accessTokenExpiresOn,
expires: token.accessTokenExpiresAt,
userId: token.userId
};
});
Expand Down Expand Up @@ -67,7 +67,7 @@ module.exports.getRefreshToken = function(bearerToken) {

return {
clientId: token.clientId,
expires: token.refreshTokenExpiresOn,
expires: token.refreshTokenExpiresAt,
refreshToken: token.accessToken,
userId: token.userId
};
Expand Down