Permalink
Browse files

Merged pull request #2 from DveMac/master.

Untitled
  • Loading branch information...
xrd committed Apr 25, 2011
2 parents 8886a22 + 9e126ec commit d3d994ff6bcff098104a636971ee9f2039a34619
Showing with 18 additions and 18 deletions.
  1. +3 −3 README.rdoc
  2. +2 −2 example/app.js
  3. +13 −13 lib/connect-rpx.js
View
@@ -7,7 +7,7 @@ http://github.com/extjs/Connect
== Usage:
var Connect = require('connect');
- var MemoryStore = require('connect/middleware/session/memory');
+ var MemoryStore = require('connect').session.MemoryStore;
var RPX = require( 'connect-rpx' );
// Setup RPX
@@ -44,7 +44,7 @@ http://github.com/extjs/Connect
var Server = module.exports = Connect.createServer(
Connect.logger(),
Connect.cookieDecoder(),
- Connect.session({ store: new MemoryStore({ reapInterval: minute, maxAge: minute * 5 }) }),
+ Connect.session({ secret: 'your_secrets_safe_with_me', store: new MemoryStore({ reapInterval: minute, maxAge: minute * 5 }) }),
RPX.handler(),
Connect.staticProvider( root ) // this is not strictly required, );
@@ -70,4 +70,4 @@ http://github.com/extjs/Connect
== THANKS
-This code was based on the rack-rpx module http://github.com/pedrodelgallego/rack-rpx
+This code was based on the rack-rpx module http://github.com/pedrodelgallego/rack-rpx
View
@@ -1,5 +1,5 @@
var Connect = require('connect');
-var MemoryStore = require('connect/middleware/session/memory');
+var MemoryStore = require('connect').session.MemoryStore;
var RPX = require( 'connect-rpx' );
// Setup RPX
@@ -40,7 +40,7 @@ var Server = module.exports = Connect.createServer(
// Body decoder used to be required, but is no longer. If you want to use it, you can install it here, or leave it out
// Connect.bodyDecoder(),
Connect.cookieDecoder(),
- Connect.session({ store: new MemoryStore({ reapInterval: minute, maxAge: minute * 5 }) }),
+ Connect.session({ secret: 'your_secrets_safe_with_me', store: new MemoryStore({ reapInterval: minute, maxAge: minute * 5 }) }),
RPX.handler(),
Connect.staticProvider( root ) // this is not strictly required,
);
View
@@ -1,12 +1,12 @@
var sys = require('sys');
var fs = require('fs');
-var http = require('http');
+var https = require('https');
var qs = require('querystring');
// Connect Middleware for integrating RPX Now into your application
var RPX_HOST = 'rpxnow.com';
var RPX_LOGIN_ROOT = "/api/v2/auth_info";
-var RPX_LOGIN_URL = "https://rpxnow.com/api/v2/auth_info";
+//var RPX_LOGIN_URL = "/api/v2/auth_info";
var options = {
callback_path : '/login_completed',
@@ -64,21 +64,20 @@ function postWithCredentials( token, req, res, next ) {
'Content-Type' : 'application/x-www-form-urlencoded',
'Content-Length' : toPost.length };
var rpxResponseBody = '';
- var postRequest = http.createClient( 443, RPX_HOST, true ).request( 'POST', RPX_LOGIN_ROOT, toPostHeader );
- postRequest.write( toPost, 'utf8' );
- postRequest.on( 'response', function(rpxResponse) {
- rpxResponse.on( 'data', function( data ) {
- // sys.puts( "Chunk: " + data );
+ var postRequest = https.request( { port:443, host: RPX_HOST, path: RPX_LOGIN_ROOT, method: 'POST', headers: toPostHeader }, function(rpxResponse) {
+ rpxResponse.on( 'data', function( data ) {
rpxResponseBody += data;
- } );
- rpxResponse.on( 'end', function() { onCredentialsReceived( rpxResponseBody, req, res, next ) } );
- rpxResponse.on( 'error', onError );
- });
- postRequest.end();
+ });
+
+ rpxResponse.on( 'end', function() { onCredentialsReceived( rpxResponseBody, req, res, next ) } );
+ rpxResponse.on( 'error', onError );
+ });
+ postRequest.on( 'error', onError );
+ postRequest.end(toPost, 'utf8' );
}
function onError(response) {
- sys.puts( "Something bad happened" );
+ sys.puts( "Something bad happened: " + response );
}
function onCredentialsReceived(data, req, res, next) {
@@ -88,6 +87,7 @@ function onCredentialsReceived(data, req, res, next) {
json = JSON.parse( data );
}
catch( e ) {
+ sys.puts(data);
sys.puts( "E: " + sys.inspect( e ) );
}
}

0 comments on commit d3d994f

Please sign in to comment.