Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert committed Oct 9, 2015
1 parent e026faf commit 5f4994a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/upgrading.rst
Expand Up @@ -10,7 +10,7 @@ Express-Stormpath releases.
Version 2.0.9 -> Version 2.0.10
-------------------------------

We were looking for the option ``config.web.regisgter.autoAuthorize``, to
We were looking for the option ``config.web.register.autoAuthorize``, to
enable the auto-login-after-registration feature. This should actually be
``autoLogin``, and it is documented as this. The library is now looking for
this option as ``autoLogin``, so you will need to change your configuration it
Expand Down
29 changes: 14 additions & 15 deletions lib/controllers/register.js
Expand Up @@ -56,17 +56,16 @@ function defaultAutoAuthorizeHtmlResponse(config,req,res){

/**
* Delivers the default response for registration attempts that accept a JSON
* content type, where the new account is in a verified state and the config
* has requested that we automatically log in the user. In this situation we
* simply return the user object as JSON
* content type. In this situation we simply return the new account object as
* JSON
*
* @function
*
* @param {Object} config - The express-stormpath configuration object
* @param {Object} req - The http request.
* @param {Object} res - The http response.
*/
function defaultAutoAuthorizeJsonResponse(req,res){
function defaultJsonResponse(req,res){
res.json(req.user);
}

Expand Down Expand Up @@ -111,18 +110,18 @@ module.exports = function(req, res) {
if (err) {
return res.status(400).json({ errors: [new Error(err.userMessage || err.message)] });
}
helpers.createSession(passwordGrantAuthenticationResult, account, req, res);
helpers.createSession(passwordGrantAuthenticationResult, expandedAccount, req, res);
if (postRegistrationHandler) {
return postRegistrationHandler(req.user, req, res, defaultAutoAuthorizeJsonResponse.bind(null,req,res));
return postRegistrationHandler(expandedAccount, req, res, defaultJsonResponse.bind(null,req,res));
}
defaultAutoAuthorizeJsonResponse(req,res);
defaultJsonResponse(req,res);
});
}

if (postRegistrationHandler) {
return postRegistrationHandler(req.user, req, res, defaultAutoAuthorizeJsonResponse.bind(null,req,res));
return postRegistrationHandler(expandedAccount, req, res, defaultJsonResponse.bind(null,req,res));
}
defaultAutoAuthorizeJsonResponse(req,res);
defaultJsonResponse(req,res);
});

});
Expand Down Expand Up @@ -198,12 +197,12 @@ module.exports = function(req, res) {
// user on the login page.

helpers.expandAccount(req.app,account,function(err,expandedAccount){
req.user = account = expandedAccount;
req.user = expandedAccount;

if (account.status === 'UNVERIFIED') {
if (expandedAccount.status === 'UNVERIFIED') {

if (postRegistrationHandler) {
return postRegistrationHandler(req.user, req, res, defaultUnverifiedHtmlResponse.bind(null,config,res));
return postRegistrationHandler(expandedAccount, req, res, defaultUnverifiedHtmlResponse.bind(null,config,res));
}
return defaultUnverifiedHtmlResponse(config,res);
}
Expand All @@ -216,16 +215,16 @@ module.exports = function(req, res) {
if (err) {
return res.status(400).json({ errors: [new Error(err.userMessage || err.message)] });
}
helpers.createSession(passwordGrantAuthenticationResult, account, req, res);
helpers.createSession(passwordGrantAuthenticationResult, expandedAccount, req, res);
if (postRegistrationHandler) {
return postRegistrationHandler(req.user, req, res, defaultAutoAuthorizeHtmlResponse.bind(null,config,req,res));
return postRegistrationHandler(expandedAccount, req, res, defaultAutoAuthorizeHtmlResponse.bind(null,config,req,res));
}
defaultAutoAuthorizeHtmlResponse(config,req,res);
});
}

if (postRegistrationHandler) {
return postRegistrationHandler(req.user, req, res, function() {
return postRegistrationHandler(expandedAccount, req, res, function() {
return defaultCreatedHtmlResponse(config,res);
});
}
Expand Down

0 comments on commit 5f4994a

Please sign in to comment.