Skip to content

Commit

Permalink
Some cleanup.
Browse files Browse the repository at this point in the history
Signed-off-by: François de Metz <fdemetz@af83.com>
  • Loading branch information
francois2metz committed Apr 11, 2011
1 parent 903b6e7 commit d638206
Showing 1 changed file with 21 additions and 23 deletions.
44 changes: 21 additions & 23 deletions lib/server.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -38,25 +38,25 @@ function server_error(res, err) {
var SERVER = exports; var SERVER = exports;
// To be set by connect middleware: SERVER.RFactory, SERVER.authentication // To be set by connect middleware: SERVER.RFactory, SERVER.authentication


/* Render a particular error.
*
* Arguments:
* - res
* - type: the class of the error ('eua' or 'oat').
* - id: the id of the error (invalid_request, invalid_client...).
*/
SERVER.oauth_error = function(res, type, id) { SERVER.oauth_error = function(res, type, id) {
/* Render a particular error.
*
* Arguments:
* - res
* - type: the class of the error ('eua' or 'oat').
* - id: the id of the error (invalid_request, invalid_client...).
*/
res.writeHead(400, {'Content-Type': 'text/plain'}); res.writeHead(400, {'Content-Type': 'text/plain'});
res.end(JSON.stringify({error: { res.end(JSON.stringify({error: {
type: 'OAuthException', type: 'OAuthException',
message: id + ': ' + oauth2.ERRORS[type][id], message: id + ': ' + oauth2.ERRORS[type][id],
}})); }}));
}; };



/**
* To call when an unknown error happens (server error).
*/
var unknown_error = exports.unknown_error = function(res, err) { var unknown_error = exports.unknown_error = function(res, err) {
/* To call when an unknown error happens (server error).
*/
server_error(res, err); server_error(res, err);
}; };


Expand Down Expand Up @@ -96,7 +96,6 @@ PARAMS.eua.all = PARAMS.eua.mandatory.concat(PARAMS.eua.optional);
* *
*/ */
exports.send_grant = function(res, Grant, user_id, client_data, additional_info) { exports.send_grant = function(res, Grant, user_id, client_data, additional_info) {
console.log(client_data);
var grant = new Grant({ var grant = new Grant({
client_id: client_data.client_id, client_id: client_data.client_id,
time: Date.now(), time: Date.now(),
Expand Down Expand Up @@ -221,19 +220,18 @@ var token_endpoint = exports.token_endpoint = function(req, res) {
}); });
}; };



/* OAuth2 Authorize function.
* Serve an authentication form to the end user at browser.
*
* This function should only be called by oauth2.authorize
*
* Arguments:
* - params:
* - req
* - res
*
*/
SERVER.authorize = function(params, req, res) { SERVER.authorize = function(params, req, res) {
/* OAuth2 Authorize function.
* Serve an authentication form to the end user at browser.
*
* This function should only be called by oauth2.authorize
*
* Arguments:
* - params:
* - req
* - res
*
*/
// We check there is no invalid_requet error: // We check there is no invalid_requet error:
var error = false; var error = false;
PARAMS.eua.mandatory.forEach(function(param) { PARAMS.eua.mandatory.forEach(function(param) {
Expand Down

0 comments on commit d638206

Please sign in to comment.