pump-io / pump.io

Social server with an ActivityStreams API
http://pump.io/
Apache License 2.0
2.22k stars 332 forks source link

memory database driver does not work with register app #1115

Open h4ck3rm1k3 opened 9 years ago

h4ck3rm1k3 commented 9 years ago

Using the register app and authorize does not work with the default memory database driver:

./bin/pump-register-app  -t app-name
/bin/pump-authorize -u test 

The error is that it cannot find the registration. Message is "Invalid Consumer Key" from this method exports.OAuthServices.prototype.requestToken https://github.com/christkv/node-express-oauth-plugin/blob/269aacf76a43da5ef61bc7be50c5bc30ba20b0cf/lib/oauth/oauth_services.js#L117

This goes away if I use the memcached backend.

ljluestc commented 3 months ago
exports.OAuthServices.prototype.requestToken = function (req, res) {
    var consumerKey = req.body.oauth_consumer_key;
    var consumerSecret = req.body.oauth_consumer_secret;

    console.log('Request Token: ', consumerKey, consumerSecret);

    // Check the consumer key and secret in the database
    this.findConsumer(consumerKey, function (err, consumer) {
        if (err || !consumer) {
            console.error('Invalid Consumer Key:', consumerKey);
            return res.status(401).send('Invalid Consumer Key');
        }

        // Validate the consumer secret
        if (consumer.secret !== consumerSecret) {
            console.error('Invalid Consumer Secret for Key:', consumerKey);
            return res.status(401).send('Invalid Consumer Secret');
        }

        // Proceed with token generation
        // ...
    });
};